2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 // $XConsortium: PQTest.cc /main/3 1996/06/11 17:07:26 cde-hal $
27 #include "PathQualifier.h"
29 #include "Attribute.h"
30 #include "AttributeList.h"
40 Renderer *gRenderer = 0;
46 Attribute *attr1a = new Attribute(symtab.intern("attr1a"),"one-a");
47 Attribute *attr1b = new Attribute(symtab.intern("attr1b"),"one-b");
49 AttributeList *alist1 = new AttributeList ;
53 Element one(symtab.intern("One"), 1, alist1, 0);
54 Element two(symtab.intern("Two"), 2, 0, 0);
56 PQPosition posn_eq(PQEqual, 1);
57 PQPosition posn_neq(PQNotEqual, 1);
59 // /////////////////////////////////////////////////////////////////////////
61 // /////////////////////////////////////////////////////////////////////////
64 /* -------- Test Position Equal -------- */
65 cout << posn_eq.evaluate (one) << endl; // 1
66 cout << posn_eq.evaluate (two) << endl; // 0
67 cout << "---" << endl;
68 /* -------- Test Position Not Equal -------- */
69 cout << posn_neq.evaluate (one) << endl; // 0
70 cout << posn_neq.evaluate (two) << endl; // 1
71 cout << "---" << endl;
73 // ///////////////////////////////////////////////////////////////////////
74 // Test Attribute Comparison
75 // ///////////////////////////////////////////////////////////////////////
77 PQAttributeSelector pqas_eqa(symtab.intern("attr1a"), PQEqual, "one-a");
78 PQAttributeSelector pqas_eqb(symtab.intern("attr1a"), PQEqual, "one-b");
79 PQAttributeSelector pqas_neqa(symtab.intern("attr1a"), PQNotEqual, "one-a");
80 PQAttributeSelector pqas_neqb(symtab.intern("attr1a"), PQNotEqual, "one-b");
82 PQAttributeSelector pqas_eqa2(symtab.intern("attr2a"), PQEqual, "one-a");
83 PQAttributeSelector pqas_eqb2(symtab.intern("attr2a"), PQEqual, "one-b");
84 PQAttributeSelector pqas_neqa2(symtab.intern("attr2a"), PQNotEqual, "one-a");
85 PQAttributeSelector pqas_neqb2(symtab.intern("attr2a"), PQNotEqual, "one-b");
87 cout << pqas_eqa.evaluate(one) << endl ; // 1
88 cout << pqas_eqa.evaluate(two) << endl ; // 0
90 cout << pqas_eqb.evaluate(one) << endl ; // 0
91 cout << pqas_eqb.evaluate(two) << endl ; // 0
93 cout << pqas_neqa.evaluate(one) << endl ; // 0
94 cout << pqas_neqa.evaluate(two) << endl ; // 1
96 cout << pqas_neqb.evaluate(one) << endl ; // 1
97 cout << pqas_neqb.evaluate(two) << endl ; // 1
99 cout << pqas_eqa2.evaluate(one) << endl ; // 0
100 cout << pqas_eqa2.evaluate(two) << endl ; // 0
102 cout << pqas_eqb2.evaluate(one) << endl ; // 0
103 cout << pqas_eqb2.evaluate(two) << endl ; // 0
105 cout << pqas_neqa2.evaluate(one) << endl ; // 1
106 cout << pqas_neqa2.evaluate(two) << endl ; // 1
108 cout << pqas_neqb2.evaluate(one) << endl ; // 1
109 cout << pqas_neqb2.evaluate(two) << endl ; // 1
111 cout << "****" << endl;
113 // ///////////////////////////////////////////////////////////////////////
115 // ///////////////////////////////////////////////////////////////////////
118 // position = 1 and attr(attr1a) == "one-a"
120 PQPosition *p1 = new PQPosition(PQEqual, 1);
121 PQAttributeSelector *a1 = new PQAttributeSelector(symtab.intern("attr1a"),
124 PQAttributeSelector *a2 = new PQAttributeSelector(symtab.intern("attr1a"),
127 PQLogExpr l1 (p1, PQand, a1);
128 PQLogExpr l2 (p1, PQor, a1);
129 PQLogExpr l3 (p1, PQand, a2);
130 PQLogExpr l4 (p1, PQor, a2);
132 cout << l1.evaluate(one) << endl ; // 1
133 cout << l1.evaluate(two) << endl ; // 0
135 cout << l2.evaluate(one) << endl ; // 1
136 cout << l2.evaluate(two) << endl ; // 0
138 cout << l3.evaluate(one) << endl ; // 0
139 cout << l3.evaluate(two) << endl ; // 0
141 cout << l4.evaluate(one) << endl ; // 1
142 cout << l4.evaluate(two) << endl ; // 0
144 cout << "..." << endl;
145 cout << PQNot(&l4).evaluate(one) << endl ; // 0
146 cout << PQNot(&l4).evaluate(two) << endl ; // 1