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.arrays.typed;
022:
023: import com.db4o.query.*;
024: import com.db4o.test.legacy.soda.*;
025:
026: public class STArrIntegerT implements STClass1 {
027:
028: public static transient SodaTest st;
029:
030: public int[] intArr;
031:
032: public STArrIntegerT() {
033: }
034:
035: public STArrIntegerT(int[] arr) {
036: intArr = arr;
037: }
038:
039: public Object[] store() {
040: return new Object[] {
041: new STArrIntegerT(),
042: new STArrIntegerT(new int[0]),
043: new STArrIntegerT(new int[] { 0, 0 }),
044: new STArrIntegerT(new int[] { 1, 17,
045: Integer.MAX_VALUE - 1 }),
046: new STArrIntegerT(new int[] { 3, 17, 25,
047: Integer.MAX_VALUE - 2 }) };
048: }
049:
050: public void testDefaultContainsOne() {
051: Query q = st.query();
052: Object[] r = store();
053: q.constrain(new STArrIntegerT(new int[] { 17 }));
054: st.expect(q, new Object[] { r[3], r[4] });
055: }
056:
057: public void testDefaultContainsTwo() {
058: Query q = st.query();
059: Object[] r = store();
060: q.constrain(new STArrIntegerT(new int[] { 17, 25 }));
061: st.expect(q, new Object[] { r[4] });
062: }
063:
064: public void testDescendOne() {
065: Query q = st.query();
066: Object[] r = store();
067: q.constrain(STArrIntegerT.class);
068: q.descend("intArr").constrain(new Integer(17));
069: st.expect(q, new Object[] { r[3], r[4] });
070: }
071:
072: public void testDescendTwo() {
073: Query q = st.query();
074: Object[] r = store();
075: q.constrain(STArrIntegerT.class);
076: Query qElements = q.descend("intArr");
077: qElements.constrain(new Integer(17));
078: qElements.constrain(new Integer(25));
079: st.expect(q, new Object[] { r[4] });
080: }
081:
082: public void testDescendSmaller() {
083: Query q = st.query();
084: Object[] r = store();
085: q.constrain(STArrIntegerT.class);
086: Query qElements = q.descend("intArr");
087: qElements.constrain(new Integer(3)).smaller();
088: st.expect(q, new Object[] { r[2], r[3] });
089: }
090:
091: public void testDescendNotSmaller() {
092: Query q = st.query();
093: Object[] r = store();
094: q.constrain(STArrIntegerT.class);
095: Query qElements = q.descend("intArr");
096: qElements.constrain(new Integer(3)).smaller();
097: st.expect(q, new Object[] { r[2], r[3] });
098: }
099:
100: }
|