01: /* Copyright (C) 2004 - 2007 db4objects Inc. http://www.db4o.com
02:
03: This file is part of the db4o open source object database.
04:
05: db4o is free software; you can redistribute it and/or modify it under
06: the terms of version 2 of the GNU General Public License as published
07: by the Free Software Foundation and as clarified by db4objects' GPL
08: interpretation policy, available at
09: http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
10: Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
11: Suite 350, San Mateo, CA 94403, USA.
12:
13: db4o is distributed in the hope that it will be useful, but WITHOUT ANY
14: WARRANTY; without even the implied warranty of MERCHANTABILITY or
15: FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16: for more details.
17:
18: You should have received a copy of the GNU General Public License along
19: with this program; if not, write to the Free Software Foundation, Inc.,
20: 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21: package com.db4o.db4ounit.common.soda.classes.simple;
22:
23: import com.db4o.query.*;
24:
25: public class STLongTestCase extends
26: com.db4o.db4ounit.common.soda.util.SodaBaseTestCase {
27:
28: public long i_long;
29:
30: public STLongTestCase() {
31: }
32:
33: private STLongTestCase(long a_long) {
34: i_long = a_long;
35: }
36:
37: public Object[] createData() {
38: return new Object[] { new STLongTestCase(Long.MIN_VALUE),
39: new STLongTestCase(-1), new STLongTestCase(0),
40: new STLongTestCase(Long.MAX_VALUE - 1), };
41: }
42:
43: public void testEquals() {
44: Query q = newQuery();
45: q.constrain(new STLongTestCase(Long.MIN_VALUE));
46: com.db4o.db4ounit.common.soda.util.SodaTestUtil.expect(q,
47: new Object[] { new STLongTestCase(Long.MIN_VALUE) });
48: }
49:
50: public void testGreater() {
51: Query q = newQuery();
52: q.constrain(new STLongTestCase(-1));
53: q.descend("i_long").constraints().greater();
54:
55: expect(q, new int[] { 2, 3 });
56: }
57:
58: public void testSmaller() {
59: Query q = newQuery();
60: q.constrain(new STLongTestCase(1));
61: q.descend("i_long").constraints().smaller();
62:
63: expect(q, new int[] { 0, 1, 2 });
64: }
65:
66: public void testBetween() {
67: Query q = newQuery();
68: q.constrain(new STLongTestCase());
69: Query sub = q.descend("i_long");
70: sub.constrain(new Long(-3)).greater();
71: sub.constrain(new Long(3)).smaller();
72:
73: expect(q, new int[] { 1, 2 });
74: }
75:
76: public void testAnd() {
77: Query q = newQuery();
78: q.constrain(new STLongTestCase());
79: Query sub = q.descend("i_long");
80: sub.constrain(new Long(-3)).greater().and(
81: sub.constrain(new Long(3)).smaller());
82:
83: expect(q, new int[] { 1, 2 });
84: }
85:
86: public void testOr() {
87: Query q = newQuery();
88: q.constrain(new STLongTestCase());
89: Query sub = q.descend("i_long");
90: sub.constrain(new Long(3)).greater().or(
91: sub.constrain(new Long(-3)).smaller());
92:
93: expect(q, new int[] { 0, 3 });
94: }
95:
96: }
|