1 21 package com.db4o.db4ounit.jre12.soda.collections; 22 import java.util.*; 23 24 import com.db4o.query.*; 25 26 27 public class STTreeSetTTestCase extends com.db4o.db4ounit.common.soda.util.SodaBaseTestCase { 28 29 TreeSet col; 30 31 public STTreeSetTTestCase() { 32 } 33 34 public STTreeSetTTestCase(Object [] arr) { 35 col = new TreeSet(); 36 for (int i = 0; i < arr.length; i++) { 37 col.add(arr[i]); 38 } 39 } 40 41 public Object [] createData() { 42 return new Object [] { 43 new STTreeSetTTestCase(), 44 new STTreeSetTTestCase(new Object [0]), 45 new STTreeSetTTestCase(new Object [] { new Integer (0), new Integer (0)}), 46 new STTreeSetTTestCase( 47 new Object [] { 48 new Integer (1), 49 new Integer (17), 50 new Integer (Integer.MAX_VALUE - 1)}), 51 new STTreeSetTTestCase( 52 new Object [] { 53 new Integer (3), 54 new Integer (17), 55 new Integer (25), 56 new Integer (Integer.MAX_VALUE - 2)}) 57 }; 58 } 59 60 public void testDefaultContainsInteger() { 61 Query q = newQuery(); 62 63 q.constrain(new STTreeSetTTestCase(new Object [] { new Integer (17)})); 64 expect(q, new int[] { 3, 4 }); 65 } 66 67 public void testDefaultContainsTwo() { 68 Query q = newQuery(); 69 70 q.constrain(new STTreeSetTTestCase(new Object [] { new Integer (17), new Integer (25)})); 71 expect(q, new int[] { 4 }); 72 } 73 74 public void testDescendOne() { 75 Query q = newQuery(); 76 77 q.constrain(STTreeSetTTestCase.class); 78 q.descend("col").constrain(new Integer (17)); 79 expect(q, new int[] { 3, 4 }); 80 } 81 82 public void testDescendTwo() { 83 Query q = newQuery(); 84 85 q.constrain(STTreeSetTTestCase.class); 86 Query qElements = q.descend("col"); 87 qElements.constrain(new Integer (17)); 88 qElements.constrain(new Integer (25)); 89 expect(q, new int[] { 4 }); 90 } 91 92 public void testDescendSmaller() { 93 Query q = newQuery(); 94 95 q.constrain(STTreeSetTTestCase.class); 96 Query qElements = q.descend("col"); 97 qElements.constrain(new Integer (3)).smaller(); 98 expect(q, new int[] { 2, 3 }); 99 } 100 101 102 } | Popular Tags |