1 21 package com.db4o.db4ounit.jre12.soda.collections; 22 import java.util.*; 23 24 import com.db4o.query.*; 25 26 27 28 public class STHashtableETTestCase extends com.db4o.db4ounit.common.soda.util.SodaBaseTestCase { 29 30 public static class ExtendHashtable extends Hashtable{ 31 32 } 33 34 ExtendHashtable col; 35 36 public STHashtableETTestCase() { 37 } 38 39 public STHashtableETTestCase(Object [] arr) { 40 col = new ExtendHashtable(); 41 for (int i = 0; i < arr.length; i++) { 42 col.put(arr[i], new Integer (i)); 43 } 44 } 45 46 public Object [] createData() { 47 return new Object [] { 48 new STHashtableETTestCase(), 49 new STHashtableETTestCase(new Object [0]), 50 new STHashtableETTestCase(new Object [] { new Integer (0), new Integer (0)}), 51 new STHashtableETTestCase( 52 new Object [] { 53 new Integer (1), 54 new Integer (17), 55 new Integer (Integer.MAX_VALUE - 1)}), 56 new STHashtableETTestCase( 57 new Object [] { 58 new Integer (3), 59 new Integer (17), 60 new Integer (25), 61 new Integer (Integer.MAX_VALUE - 2)}), 62 new STHashtableETTestCase(new Object [] { "foo", new STElement("bar", "barbar")}), 63 new STHashtableETTestCase(new Object [] { "foo2", new STElement("bar", "barbar2")}) 64 }; 65 } 66 67 public void testDefaultContainsInteger() { 68 Query q = newQuery(); 69 70 q.constrain(new STHashtableETTestCase(new Object [] { new Integer (17)})); 71 expect(q, new int[] { 3, 4 }); 72 } 73 74 public void testDefaultContainsString() { 75 Query q = newQuery(); 76 77 q.constrain(new STHashtableETTestCase(new Object [] { "foo" })); 78 expect(q, new int[] { 5 }); 79 } 80 81 public void testDefaultContainsTwo() { 82 Query q = newQuery(); 83 84 q.constrain(new STHashtableETTestCase(new Object [] { new Integer (17), new Integer (25)})); 85 expect(q, new int[] { 4 }); 86 } 87 88 public void testDescendOne() { 89 Query q = newQuery(); 90 91 q.constrain(STHashtableETTestCase.class); 92 q.descend("col").constrain(new Integer (17)); 93 expect(q, new int[] { 3, 4 }); 94 } 95 96 public void testDescendTwo() { 97 Query q = newQuery(); 98 99 q.constrain(STHashtableETTestCase.class); 100 Query qElements = q.descend("col"); 101 qElements.constrain(new Integer (17)); 102 qElements.constrain(new Integer (25)); 103 expect(q, new int[] { 4 }); 104 } 105 106 public void testDescendSmaller() { 107 Query q = newQuery(); 108 109 q.constrain(STHashtableETTestCase.class); 110 Query qElements = q.descend("col"); 111 qElements.constrain(new Integer (3)).smaller(); 112 expect(q, new int[] { 2, 3 }); 113 } 114 115 public void testDefaultContainsObject() { 116 Query q = newQuery(); 117 118 q.constrain(new STHashtableETTestCase(new Object [] { new STElement("bar", null)})); 119 expect(q, new int[] { 5, 6 }); 120 } 121 122 public void testDescendToObject() { 123 Query q = newQuery(); 124 125 q.constrain(new STHashtableETTestCase()); 126 q.descend("col").descend("foo1").constrain("bar"); 127 expect(q, new int[] { 5, 6 }); 128 } 129 130 } | Popular Tags |