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.test.legacy.soda.classes.simple;
22:
23: import com.db4o.query.*;
24: import com.db4o.test.legacy.soda.*;
25:
26: public class STLong implements STClass1 {
27:
28: public static transient SodaTest st;
29:
30: public long i_long;
31:
32: public STLong() {
33: }
34:
35: private STLong(long a_long) {
36: i_long = a_long;
37: }
38:
39: public Object[] store() {
40: return new Object[] { new STLong(Long.MIN_VALUE),
41: new STLong(-1), new STLong(0),
42: new STLong(Long.MAX_VALUE - 1), };
43: }
44:
45: public void testEquals() {
46: Query q = st.query();
47: q.constrain(new STLong(Long.MIN_VALUE));
48: st.expect(q, new Object[] { new STLong(Long.MIN_VALUE) });
49: }
50:
51: public void testGreater() {
52: Query q = st.query();
53: q.constrain(new STLong(-1));
54: q.descend("i_long").constraints().greater();
55: Object[] r = store();
56: st.expect(q, new Object[] { r[2], r[3] });
57: }
58:
59: public void testSmaller() {
60: Query q = st.query();
61: q.constrain(new STLong(1));
62: q.descend("i_long").constraints().smaller();
63: Object[] r = store();
64: st.expect(q, new Object[] { r[0], r[1], r[2] });
65: }
66:
67: public void testBetween() {
68: Query q = st.query();
69: q.constrain(new STLong());
70: Query sub = q.descend("i_long");
71: sub.constrain(new Long(-3)).greater();
72: sub.constrain(new Long(3)).smaller();
73: Object[] r = store();
74: st.expect(q, new Object[] { r[1], r[2] });
75: }
76:
77: public void testAnd() {
78: Query q = st.query();
79: q.constrain(new STLong());
80: Query sub = q.descend("i_long");
81: sub.constrain(new Long(-3)).greater().and(
82: sub.constrain(new Long(3)).smaller());
83: Object[] r = store();
84: st.expect(q, new Object[] { r[1], r[2] });
85: }
86:
87: public void testOr() {
88: Query q = st.query();
89: q.constrain(new STLong());
90: Query sub = q.descend("i_long");
91: sub.constrain(new Long(3)).greater().or(
92: sub.constrain(new Long(-3)).smaller());
93: Object[] r = store();
94: st.expect(q, new Object[] { r[0], r[3] });
95: }
96:
97: }
|