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.wrapper.typed;
22:
23: import com.db4o.query.*;
24: import com.db4o.test.legacy.soda.*;
25:
26: public class STBooleanWT implements STClass {
27:
28: final static String DESCENDANT = "i_boolean";
29:
30: public static transient SodaTest st;
31:
32: Boolean i_boolean;
33:
34: public STBooleanWT() {
35: }
36:
37: private STBooleanWT(boolean a_boolean) {
38: i_boolean = new Boolean(a_boolean);
39: }
40:
41: public Object[] store() {
42: return new Object[] { new STBooleanWT(false),
43: new STBooleanWT(true), new STBooleanWT(false),
44: new STBooleanWT(false), new STBooleanWT() };
45: }
46:
47: public void testEqualsTrue() {
48: Query q = st.query();
49: q.constrain(new STBooleanWT(true));
50: Object[] r = store();
51: st.expectOne(q, new STBooleanWT(true));
52: }
53:
54: public void testEqualsFalse() {
55: Query q = st.query();
56: q.constrain(new STBooleanWT(false));
57: q.descend(DESCENDANT).constrain(new Boolean(false));
58: Object[] r = store();
59: st.expect(q, new Object[] { r[0], r[2], r[3] });
60: }
61:
62: public void testNull() {
63: Query q = st.query();
64: q.constrain(new STBooleanWT());
65: q.descend(DESCENDANT).constrain(null);
66: Object[] r = store();
67: st.expectOne(q, new STBooleanWT());
68: }
69:
70: public void testNullOrTrue() {
71: Query q = st.query();
72: q.constrain(new STBooleanWT());
73: Query qd = q.descend(DESCENDANT);
74: qd.constrain(null).or(qd.constrain(new Boolean(true)));
75: Object[] r = store();
76: st.expect(q, new Object[] { r[1], r[4] });
77: }
78:
79: public void testNotNullAndFalse() {
80: Query q = st.query();
81: q.constrain(new STBooleanWT());
82: Query qd = q.descend(DESCENDANT);
83: qd.constrain(null).not().and(qd.constrain(new Boolean(false)));
84: Object[] r = store();
85: st.expect(q, new Object[] { r[0], r[2], r[3] });
86: }
87:
88: }
|