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.object;
022:
023: import com.db4o.query.*;
024: import com.db4o.test.legacy.soda.*;
025:
026: public class STArrIntegerON implements STClass {
027:
028: public static transient SodaTest st;
029:
030: Object intArr;
031:
032: public STArrIntegerON() {
033: }
034:
035: public STArrIntegerON(int[][][] arr) {
036: intArr = arr;
037: }
038:
039: public Object[] store() {
040: STArrIntegerON[] arr = new STArrIntegerON[5];
041:
042: arr[0] = new STArrIntegerON();
043:
044: int[][][] content = new int[0][0][0];
045: arr[1] = new STArrIntegerON(content);
046:
047: content = new int[1][2][3];
048: content[0][0][1] = 0;
049: content[0][1][0] = 0;
050: arr[2] = new STArrIntegerON(content);
051:
052: content = new int[1][2][3];
053: content[0][0][0] = 1;
054: content[0][1][0] = 17;
055: content[0][1][1] = Integer.MAX_VALUE - 1;
056: arr[3] = new STArrIntegerON(content);
057:
058: content = new int[1][2][2];
059: content[0][0][0] = 3;
060: content[0][0][1] = 17;
061: content[0][1][0] = 25;
062: content[0][1][1] = Integer.MAX_VALUE - 2;
063: arr[4] = new STArrIntegerON(content);
064:
065: Object[] ret = new Object[arr.length];
066: System.arraycopy(arr, 0, ret, 0, arr.length);
067: return ret;
068: }
069:
070: public void testDefaultContainsOne() {
071: Query q = st.query();
072: Object[] r = store();
073: int[][][] content = new int[1][1][1];
074: content[0][0][0] = 17;
075: q.constrain(new STArrIntegerON(content));
076: st.expect(q, new Object[] { r[3], r[4] });
077: }
078:
079: public void testDefaultContainsTwo() {
080: Query q = st.query();
081: Object[] r = store();
082: int[][][] content = new int[2][1][1];
083: content[0][0][0] = 17;
084: content[1][0][0] = 25;
085: q.constrain(new STArrIntegerON(content));
086: st.expect(q, new Object[] { r[4] });
087: }
088:
089: public void testDescendOne() {
090: Query q = st.query();
091: Object[] r = store();
092: q.constrain(STArrIntegerON.class);
093: q.descend("intArr").constrain(new Integer(17));
094: st.expect(q, new Object[] { r[3], r[4] });
095: }
096:
097: public void testDescendTwo() {
098: Query q = st.query();
099: Object[] r = store();
100: q.constrain(STArrIntegerON.class);
101: Query qElements = q.descend("intArr");
102: qElements.constrain(new Integer(17));
103: qElements.constrain(new Integer(25));
104: st.expect(q, new Object[] { r[4] });
105: }
106:
107: public void testDescendSmaller() {
108: Query q = st.query();
109: Object[] r = store();
110: q.constrain(STArrIntegerON.class);
111: Query qElements = q.descend("intArr");
112: qElements.constrain(new Integer(3)).smaller();
113: st.expect(q, new Object[] { r[2], r[3] });
114: }
115:
116: public void testDescendNotSmaller() {
117: Query q = st.query();
118: Object[] r = store();
119: q.constrain(STArrIntegerON.class);
120: Query qElements = q.descend("intArr");
121: qElements.constrain(new Integer(3)).smaller();
122: st.expect(q, new Object[] { r[2], r[3] });
123: }
124:
125: }
|