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