1 21 package com.db4o.db4ounit.common.soda.classes.simple; 22 import com.db4o.*; 23 import com.db4o.query.*; 24 25 26 public class STByteTestCase extends com.db4o.db4ounit.common.soda.util.SodaBaseTestCase{ 27 28 final static String DESCENDANT = "i_byte"; 29 30 public byte i_byte; 31 32 33 public STByteTestCase(){ 34 } 35 36 private STByteTestCase(byte a_byte){ 37 i_byte = a_byte; 38 } 39 40 public Object [] createData() { 41 return new Object []{ 42 new STByteTestCase((byte)0), 43 new STByteTestCase((byte)1), 44 new STByteTestCase((byte)99), 45 new STByteTestCase((byte)113) 46 }; 47 } 48 49 public void testEquals(){ 50 Query q = newQuery(); 51 q.constrain(new STByteTestCase((byte)0)); 52 53 q.descend(DESCENDANT).constrain(new Byte ((byte)0)); 56 com.db4o.db4ounit.common.soda.util.SodaTestUtil.expectOne(q, _array[0]); 57 } 58 59 public void testNotEquals(){ 60 Query q = newQuery(); 61 62 q.constrain(_array[0]); 63 q.descend(DESCENDANT).constrain(new Byte ((byte)0)).not(); 64 expect(q, new int[] {1, 2, 3}); 65 } 66 67 public void testGreater(){ 68 Query q = newQuery(); 69 70 q.constrain(new STByteTestCase((byte)9)); 71 q.descend(DESCENDANT).constraints().greater(); 72 73 expect(q, new int[] {2, 3}); 74 } 75 76 public void testSmaller(){ 77 Query q = newQuery(); 78 79 q.constrain(new STByteTestCase((byte)1)); 80 q.descend(DESCENDANT).constraints().smaller(); 81 com.db4o.db4ounit.common.soda.util.SodaTestUtil.expectOne(q, _array[0]); 82 } 83 84 public void testContains(){ 85 Query q = newQuery(); 86 87 q.constrain(new STByteTestCase((byte)9)); 88 q.descend(DESCENDANT).constraints().contains(); 89 90 expect(q, new int[] {2}); 91 } 92 93 public void testNotContains(){ 94 Query q = newQuery(); 95 96 q.constrain(new STByteTestCase((byte)0)); 97 q.descend(DESCENDANT).constrain(new Byte ((byte)0)).contains().not(); 98 99 expect(q, new int[] {1, 2, 3}); 100 } 101 102 public void testLike(){ 103 Query q = newQuery(); 104 q.constrain(new STByteTestCase((byte)11)); 105 q.descend(DESCENDANT).constraints().like(); 106 com.db4o.db4ounit.common.soda.util.SodaTestUtil.expectOne(q, new STByteTestCase((byte)113)); 107 108 q = newQuery(); 109 q.constrain(new STByteTestCase((byte)10)); 110 q.descend(DESCENDANT).constraints().like(); 111 expect(q, new int[] {}); 112 } 113 114 public void testNotLike(){ 115 Query q = newQuery(); 116 117 q.constrain(new STByteTestCase((byte)1)); 118 q.descend(DESCENDANT).constraints().like().not(); 119 120 expect(q, new int[] {0, 2}); 121 } 122 123 public void testIdentity(){ 124 Query q = newQuery(); 125 q.constrain(new STByteTestCase((byte)1)); 126 ObjectSet set = q.execute(); 127 STByteTestCase identityConstraint = (STByteTestCase)set.next(); 128 identityConstraint.i_byte = 102; 129 q = newQuery(); 130 q.constrain(identityConstraint).identity(); 131 identityConstraint.i_byte = 1; 132 com.db4o.db4ounit.common.soda.util.SodaTestUtil.expectOne(q,_array[1]); 133 } 134 135 public void testNotIdentity(){ 136 Query q = newQuery(); 137 q.constrain(new STByteTestCase((byte)1)); 138 ObjectSet set = q.execute(); 139 STByteTestCase identityConstraint = (STByteTestCase)set.next(); 140 identityConstraint.i_byte = 102; 141 q = newQuery(); 142 q.constrain(identityConstraint).identity().not(); 143 identityConstraint.i_byte = 1; 144 145 expect(q, new int[] {0, 2, 3}); 146 } 147 148 public void testConstraints(){ 149 Query q = newQuery(); 150 q.constrain(new STByteTestCase((byte)1)); 151 q.constrain(new STByteTestCase((byte)0)); 152 Constraints cs = q.constraints(); 153 Constraint[] csa = cs.toArray(); 154 if(csa.length != 2){ 155 db4ounit.Assert.fail("Constraints not returned"); 156 } 157 } 158 159 } 160 161 | Popular Tags |