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