01: /* Copyright (C) 2004 - 2007 db4objects Inc. http://www.db4o.com
02:
03: This file is part of the db4o open source object database.
04:
05: db4o is free software; you can redistribute it and/or modify it under
06: the terms of version 2 of the GNU General Public License as published
07: by the Free Software Foundation and as clarified by db4objects' GPL
08: interpretation policy, available at
09: http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
10: Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
11: Suite 350, San Mateo, CA 94403, USA.
12:
13: db4o is distributed in the hope that it will be useful, but WITHOUT ANY
14: WARRANTY; without even the implied warranty of MERCHANTABILITY or
15: FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16: for more details.
17:
18: You should have received a copy of the GNU General Public License along
19: with this program; if not, write to the Free Software Foundation, Inc.,
20: 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21: package com.db4o.db4ounit.jre12.soda.collections;
22:
23: import java.util.*;
24:
25: import com.db4o.query.*;
26:
27: public class STTreeSetTTestCase extends
28: com.db4o.db4ounit.common.soda.util.SodaBaseTestCase {
29:
30: TreeSet col;
31:
32: public STTreeSetTTestCase() {
33: }
34:
35: public STTreeSetTTestCase(Object[] arr) {
36: col = new TreeSet();
37: for (int i = 0; i < arr.length; i++) {
38: col.add(arr[i]);
39: }
40: }
41:
42: public Object[] createData() {
43: return new Object[] {
44: new STTreeSetTTestCase(),
45: new STTreeSetTTestCase(new Object[0]),
46: new STTreeSetTTestCase(new Object[] { new Integer(0),
47: new Integer(0) }),
48: new STTreeSetTTestCase(new Object[] { new Integer(1),
49: new Integer(17),
50: new Integer(Integer.MAX_VALUE - 1) }),
51: new STTreeSetTTestCase(new Object[] { new Integer(3),
52: new Integer(17), new Integer(25),
53: new Integer(Integer.MAX_VALUE - 2) }) };
54: }
55:
56: public void testDefaultContainsInteger() {
57: Query q = newQuery();
58:
59: q.constrain(new STTreeSetTTestCase(new Object[] { new Integer(
60: 17) }));
61: expect(q, new int[] { 3, 4 });
62: }
63:
64: public void testDefaultContainsTwo() {
65: Query q = newQuery();
66:
67: q.constrain(new STTreeSetTTestCase(new Object[] {
68: new Integer(17), new Integer(25) }));
69: expect(q, new int[] { 4 });
70: }
71:
72: public void testDescendOne() {
73: Query q = newQuery();
74:
75: q.constrain(STTreeSetTTestCase.class);
76: q.descend("col").constrain(new Integer(17));
77: expect(q, new int[] { 3, 4 });
78: }
79:
80: public void testDescendTwo() {
81: Query q = newQuery();
82:
83: q.constrain(STTreeSetTTestCase.class);
84: Query qElements = q.descend("col");
85: qElements.constrain(new Integer(17));
86: qElements.constrain(new Integer(25));
87: expect(q, new int[] { 4 });
88: }
89:
90: public void testDescendSmaller() {
91: Query q = newQuery();
92:
93: q.constrain(STTreeSetTTestCase.class);
94: Query qElements = q.descend("col");
95: qElements.constrain(new Integer(3)).smaller();
96: expect(q, new int[] { 2, 3 });
97: }
98:
99: }
|