Disable all code related to libXp
[oweals/cde.git] / cde / programs / dtinfo / DtMmdb / StyleSheet / PQTest.C
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
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)
10  * any later version.
11  *
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
16  * details.
17  *
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
22  */
23 // $XConsortium: PQTest.cc /main/3 1996/06/11 17:07:26 cde-hal $
24 #include <iostream>
25 using namespace std;
26 #include "SymTab.h"
27 #include "PathQualifier.h"
28 #include "Element.h"
29 #include "Attribute.h"
30 #include "AttributeList.h"
31
32 void
33 styleerror(char *)
34 {
35   // bogus 
36   abort();
37 }
38
39 class Renderer;
40 Renderer *gRenderer = 0;
41
42 main()
43 {
44   SymbolTable symtab ;
45
46   Attribute *attr1a = new Attribute(symtab.intern("attr1a"),"one-a");
47   Attribute *attr1b = new Attribute(symtab.intern("attr1b"),"one-b");
48
49   AttributeList *alist1 = new AttributeList ;
50   alist1->add(attr1a);
51   alist1->add(attr1b);
52
53   Element one(symtab.intern("One"), 1, alist1, 0);
54   Element two(symtab.intern("Two"), 2, 0, 0);
55
56   PQPosition posn_eq(PQEqual, 1);
57   PQPosition posn_neq(PQNotEqual, 1);
58
59 // /////////////////////////////////////////////////////////////////////////
60 // Test Position
61 // /////////////////////////////////////////////////////////////////////////
62
63
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;
72
73   // ///////////////////////////////////////////////////////////////////////
74   // Test Attribute Comparison
75   // ///////////////////////////////////////////////////////////////////////
76
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");
81
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");
86
87   cout << pqas_eqa.evaluate(one) << endl ; // 1 
88   cout << pqas_eqa.evaluate(two) << endl ; // 0 
89
90   cout << pqas_eqb.evaluate(one) << endl ; // 0 
91   cout << pqas_eqb.evaluate(two) << endl ; // 0 
92
93   cout << pqas_neqa.evaluate(one) << endl ; // 0 
94   cout << pqas_neqa.evaluate(two) << endl ; // 1
95
96   cout << pqas_neqb.evaluate(one) << endl ; // 1 
97   cout << pqas_neqb.evaluate(two) << endl ; // 1 
98
99   cout << pqas_eqa2.evaluate(one) << endl ; // 0
100   cout << pqas_eqa2.evaluate(two) << endl ; // 0 
101
102   cout << pqas_eqb2.evaluate(one) << endl ; // 0 
103   cout << pqas_eqb2.evaluate(two) << endl ; // 0 
104
105   cout << pqas_neqa2.evaluate(one) << endl ; // 1 
106   cout << pqas_neqa2.evaluate(two) << endl ; // 1 
107
108   cout << pqas_neqb2.evaluate(one) << endl ; // 1 
109   cout << pqas_neqb2.evaluate(two) << endl ; // 1 
110
111   cout << "****" << endl;
112
113   // ///////////////////////////////////////////////////////////////////////
114   // composite
115   // ///////////////////////////////////////////////////////////////////////
116
117   
118     // position = 1 and attr(attr1a) == "one-a" 
119
120   PQPosition *p1 = new PQPosition(PQEqual, 1);
121   PQAttributeSelector *a1 = new PQAttributeSelector(symtab.intern("attr1a"),
122                                                     PQEqual, "one-a"); 
123
124   PQAttributeSelector *a2 = new PQAttributeSelector(symtab.intern("attr1a"),
125                                                     PQEqual, "value"); 
126
127   PQLogExpr l1 (p1, PQand, a1);
128   PQLogExpr l2 (p1, PQor,  a1);
129   PQLogExpr l3 (p1, PQand, a2);
130   PQLogExpr l4 (p1, PQor,  a2);
131
132   cout << l1.evaluate(one) << endl ; // 1 
133   cout << l1.evaluate(two) << endl ; // 0 
134   
135   cout << l2.evaluate(one) << endl ; // 1 
136   cout << l2.evaluate(two) << endl ; // 0 
137
138   cout << l3.evaluate(one) << endl ; // 0 
139   cout << l3.evaluate(two) << endl ; // 0 
140
141   cout << l4.evaluate(one) << endl ; // 1 
142   cout << l4.evaluate(two) << endl ; // 0 
143
144   cout << "..." << endl;
145   cout << PQNot(&l4).evaluate(one) << endl ; // 0 
146   cout << PQNot(&l4).evaluate(two) << endl ; // 1 
147
148   
149   
150 }