KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > db4o > db4ounit > jre12 > soda > collections > STTreeSetTTestCase


1 /* Copyright (C) 2004 - 2006 db4objects Inc. http://www.db4o.com
2
3 This file is part of the db4o open source object database.
4
5 db4o is free software; you can redistribute it and/or modify it under
6 the terms of version 2 of the GNU General Public License as published
7 by the Free Software Foundation and as clarified by db4objects' GPL
8 interpretation policy, available at
9 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 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 JavaDoc[] 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 JavaDoc[] createData() {
42         return new Object JavaDoc[] {
43             new STTreeSetTTestCase(),
44             new STTreeSetTTestCase(new Object JavaDoc[0]),
45             new STTreeSetTTestCase(new Object JavaDoc[] { new Integer JavaDoc(0), new Integer JavaDoc(0)}),
46             new STTreeSetTTestCase(
47                 new Object JavaDoc[] {
48                     new Integer JavaDoc(1),
49                     new Integer JavaDoc(17),
50                     new Integer JavaDoc(Integer.MAX_VALUE - 1)}),
51             new STTreeSetTTestCase(
52                 new Object JavaDoc[] {
53                     new Integer JavaDoc(3),
54                     new Integer JavaDoc(17),
55                     new Integer JavaDoc(25),
56                     new Integer JavaDoc(Integer.MAX_VALUE - 2)})
57         };
58     }
59
60     public void testDefaultContainsInteger() {
61         Query q = newQuery();
62         
63         q.constrain(new STTreeSetTTestCase(new Object JavaDoc[] { new Integer JavaDoc(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 JavaDoc[] { new Integer JavaDoc(17), new Integer JavaDoc(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 JavaDoc(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 JavaDoc(17));
88         qElements.constrain(new Integer JavaDoc(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 JavaDoc(3)).smaller();
98         expect(q, new int[] { 2, 3 });
99     }
100     
101
102 }
Popular Tags