001: /* Copyright (C) 2004 - 2007 db4objects Inc. http://www.db4o.com
002:
003: This file is part of the db4o open source object database.
004:
005: db4o is free software; you can redistribute it and/or modify it under
006: the terms of version 2 of the GNU General Public License as published
007: by the Free Software Foundation and as clarified by db4objects' GPL
008: interpretation policy, available at
009: http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
010: Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
011: Suite 350, San Mateo, CA 94403, USA.
012:
013: db4o is distributed in the hope that it will be useful, but WITHOUT ANY
014: WARRANTY; without even the implied warranty of MERCHANTABILITY or
015: FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
016: for more details.
017:
018: You should have received a copy of the GNU General Public License along
019: with this program; if not, write to the Free Software Foundation, Inc.,
020: 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
021: package com.db4o.test.legacy.soda.collections;
022:
023: import java.util.*;
024:
025: import com.db4o.query.*;
026: import com.db4o.test.legacy.soda.*;
027:
028: public class STTreeSetU implements STClass {
029:
030: public static transient SodaTest st;
031:
032: Object col;
033:
034: public STTreeSetU() {
035: }
036:
037: public STTreeSetU(Object[] arr) {
038: col = new TreeSet();
039: for (int i = 0; i < arr.length; i++) {
040: ((TreeSet) col).add(arr[i]);
041: }
042: }
043:
044: public Object[] store() {
045: return new Object[] {
046: new STTreeSetU(),
047: new STTreeSetU(new Object[0]),
048: new STTreeSetU(new Object[] { new Integer(0),
049: new Integer(0) }),
050: new STTreeSetU(new Object[] { new Integer(1),
051: new Integer(17),
052: new Integer(Integer.MAX_VALUE - 1) }),
053: new STTreeSetU(new Object[] { new Integer(3),
054: new Integer(17), new Integer(25),
055: new Integer(Integer.MAX_VALUE - 2) }) };
056: }
057:
058: public void testDefaultContainsInteger() {
059: Query q = st.query();
060: Object[] r = store();
061: q.constrain(new STTreeSetU(new Object[] { new Integer(17) }));
062: st.expect(q, new Object[] { r[3], r[4] });
063: }
064:
065: public void testDefaultContainsTwo() {
066: Query q = st.query();
067: Object[] r = store();
068: q.constrain(new STTreeSetU(new Object[] { new Integer(17),
069: new Integer(25) }));
070: st.expect(q, new Object[] { r[4] });
071: }
072:
073: public void testDescendOne() {
074: Query q = st.query();
075: Object[] r = store();
076: q.constrain(STTreeSetU.class);
077: q.descend("col").constrain(new Integer(17));
078: st.expect(q, new Object[] { r[3], r[4] });
079: }
080:
081: public void testDescendTwo() {
082: Query q = st.query();
083: Object[] r = store();
084: q.constrain(STTreeSetU.class);
085: Query qElements = q.descend("col");
086: qElements.constrain(new Integer(17));
087: qElements.constrain(new Integer(25));
088: st.expect(q, new Object[] { r[4] });
089: }
090:
091: public void testDescendSmaller() {
092: Query q = st.query();
093: Object[] r = store();
094: q.constrain(STTreeSetU.class);
095: Query qElements = q.descend("col");
096: qElements.constrain(new Integer(3)).smaller();
097: st.expect(q, new Object[] { r[2], r[3] });
098: }
099:
100: }
|