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