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