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