1 21 package com.db4o.test.legacy.soda.classes.simple; 22 23 import com.db4o.*; 24 import com.db4o.query.*; 25 import com.db4o.test.legacy.soda.*; 26 27 public class STChar implements STClass1{ 28 29 final static String DESCENDANT = "i_char"; 30 31 public static transient SodaTest st; 32 33 public char i_char; 34 35 public STChar(){ 36 } 37 38 private STChar(char a_char){ 39 i_char = a_char; 40 } 41 42 public Object [] store() { 43 return new Object []{ 44 new STChar((char)0), 45 new STChar((char)1), 46 new STChar((char)99), 47 new STChar((char)909) 48 }; 49 } 50 51 public void testEquals(){ 52 Query q = st.query(); 53 q.constrain(new STChar((char)0)); 54 55 q.descend(DESCENDANT).constrain(new Character ((char)0)); 58 st.expectOne(q, store()[0]); 59 } 60 61 public void testNotEquals(){ 62 Query q = st.query(); 63 Object [] r = store(); 64 Constraint c = q.constrain(r[0]); 65 q.descend(DESCENDANT).constrain(new Character ((char)0)).not(); 66 st.expect(q, new Object [] {r[1], r[2], r[3]}); 67 } 68 69 public void testGreater(){ 70 Query q = st.query(); 71 Constraint c = q.constrain(new STChar((char)9)); 72 q.descend(DESCENDANT).constraints().greater(); 73 Object [] r = store(); 74 st.expect(q, new Object [] {r[2], r[3]}); 75 } 76 77 public void testSmaller(){ 78 Query q = st.query(); 79 Constraint c = q.constrain(new STChar((char)1)); 80 q.descend(DESCENDANT).constraints().smaller(); 81 st.expectOne(q, store()[0]); 82 } 83 84 public void testIdentity(){ 85 Query q = st.query(); 86 Constraint c = q.constrain(new STChar((char)1)); 87 ObjectSet set = q.execute(); 88 STChar identityConstraint = (STChar)set.next(); 89 identityConstraint.i_char = 9999; 90 q = st.query(); 91 q.constrain(identityConstraint).identity(); 92 identityConstraint.i_char = 1; 93 st.expectOne(q,store()[1]); 94 } 95 96 public void testNotIdentity(){ 97 Query q = st.query(); 98 Constraint c = q.constrain(new STChar((char)1)); 99 ObjectSet set = q.execute(); 100 STChar identityConstraint = (STChar)set.next(); 101 identityConstraint.i_char = 9080; 102 q = st.query(); 103 q.constrain(identityConstraint).identity().not(); 104 identityConstraint.i_char = 1; 105 Object [] r = store(); 106 st.expect(q, new Object [] {r[0], r[2], r[3]}); 107 } 108 109 public void testConstraints(){ 110 Query q = st.query(); 111 q.constrain(new STChar((char)1)); 112 q.constrain(new STChar((char)0)); 113 Constraints cs = q.constraints(); 114 Constraint[] csa = cs.toArray(); 115 if(csa.length != 2){ 116 st.error("Constraints not returned"); 117 } 118 } 119 120 } 121 122 | Popular Tags |