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