11063cd1bcb66c3af56fe51518d0105a117c767c
1 /********************* */
2 /*! \file attribute_white.h
4 ** Original author: Morgan Deters
5 ** Major contributors: none
6 ** Minor contributors (to current version): Dejan Jovanovic, Christopher L. Conway
7 ** This file is part of the CVC4 project.
8 ** Copyright (c) 2009-2014 New York University and The University of Iowa
9 ** See the file COPYING in the top-level source directory for licensing
10 ** information.\endverbatim
12 ** \brief White box testing of Node attributes.
14 ** White box testing of Node attributes.
17 #include <cxxtest/TestSuite.h>
21 #include "context/context.h"
22 #include "expr/node_value.h"
23 #include "expr/node_builder.h"
24 #include "expr/node_manager.h"
25 #include "expr/attribute.h"
26 #include "expr/node_manager_attributes.h"
27 #include "expr/node.h"
28 #include "theory/theory.h"
29 #include "theory/theory_engine.h"
30 #include "theory/uf/theory_uf.h"
31 #include "util/cvc4_assert.h"
34 using namespace CVC4::kind
;
35 using namespace CVC4::context
;
36 using namespace CVC4::expr
;
37 using namespace CVC4::expr::attr
;
46 typedef Attribute
<Test1
, std::string
> TestStringAttr1
;
47 typedef Attribute
<Test2
, std::string
> TestStringAttr2
;
49 // it would be nice to have CDAttribute<> for context-dependence
50 typedef CDAttribute
<Test1
, bool> TestCDFlag
;
52 typedef Attribute
<Test1
, bool> TestFlag1
;
53 typedef Attribute
<Test2
, bool> TestFlag2
;
54 typedef Attribute
<Test3
, bool> TestFlag3
;
55 typedef Attribute
<Test4
, bool> TestFlag4
;
56 typedef Attribute
<Test5
, bool> TestFlag5
;
58 typedef CDAttribute
<Test1
, bool> TestFlag1cd
;
59 typedef CDAttribute
<Test2
, bool> TestFlag2cd
;
61 class AttributeWhite
: public CxxTest::TestSuite
{
65 NodeManagerScope
* d_scope
;
66 TypeNode
* d_booleanType
;
72 d_nm
= new NodeManager(d_ctxt
, NULL
);
73 d_scope
= new NodeManagerScope(d_nm
);
75 d_booleanType
= new TypeNode(d_nm
->booleanType());
85 void testAttributeIds() {
86 // Test that IDs for (a subset of) attributes in the system are
87 // unique and that the LastAttributeId (which would be the next ID
88 // to assign) is greater than all attribute IDs.
90 // We used to check ID assignments explicitly. However, between
91 // compilation modules, you don't get a strong guarantee
92 // (initialization order is somewhat implementation-specific, and
93 // anyway you'd have to change the tests anytime you add an
94 // attribute). So we back off, and just test that they're unique
95 // and that the next ID to be assigned is strictly greater than
96 // those that have already been assigned.
98 unsigned lastId
= attr::LastAttributeId
<string
, false>::getId();
99 TS_ASSERT_LESS_THAN(VarNameAttr::s_id
, lastId
);
100 TS_ASSERT_LESS_THAN(TestStringAttr1::s_id
, lastId
);
101 TS_ASSERT_LESS_THAN(TestStringAttr2::s_id
, lastId
);
103 TS_ASSERT_DIFFERS(VarNameAttr::s_id
, TestStringAttr1::s_id
);
104 TS_ASSERT_DIFFERS(VarNameAttr::s_id
, TestStringAttr2::s_id
);
105 TS_ASSERT_DIFFERS(TestStringAttr1::s_id
, TestStringAttr2::s_id
);
107 //lastId = attr::LastAttributeId<void*, false>::getId();
108 //TS_ASSERT_LESS_THAN(theory::uf::ECAttr::s_id, lastId);
110 lastId
= attr::LastAttributeId
<bool, false>::getId();
111 TS_ASSERT_LESS_THAN(TestFlag1::s_id
, lastId
);
112 TS_ASSERT_LESS_THAN(TestFlag2::s_id
, lastId
);
113 TS_ASSERT_LESS_THAN(TestFlag3::s_id
, lastId
);
114 TS_ASSERT_LESS_THAN(TestFlag4::s_id
, lastId
);
115 TS_ASSERT_LESS_THAN(TestFlag5::s_id
, lastId
);
116 TS_ASSERT_DIFFERS(TestFlag1::s_id
, TestFlag2::s_id
);
117 TS_ASSERT_DIFFERS(TestFlag1::s_id
, TestFlag3::s_id
);
118 TS_ASSERT_DIFFERS(TestFlag1::s_id
, TestFlag4::s_id
);
119 TS_ASSERT_DIFFERS(TestFlag1::s_id
, TestFlag5::s_id
);
120 TS_ASSERT_DIFFERS(TestFlag2::s_id
, TestFlag3::s_id
);
121 TS_ASSERT_DIFFERS(TestFlag2::s_id
, TestFlag4::s_id
);
122 TS_ASSERT_DIFFERS(TestFlag2::s_id
, TestFlag5::s_id
);
123 TS_ASSERT_DIFFERS(TestFlag3::s_id
, TestFlag4::s_id
);
124 TS_ASSERT_DIFFERS(TestFlag3::s_id
, TestFlag5::s_id
);
125 TS_ASSERT_DIFFERS(TestFlag4::s_id
, TestFlag5::s_id
);
127 lastId
= attr::LastAttributeId
<bool, true>::getId();
128 TS_ASSERT_LESS_THAN(TestFlag1cd::s_id
, lastId
);
129 TS_ASSERT_LESS_THAN(TestFlag2cd::s_id
, lastId
);
130 TS_ASSERT_DIFFERS(TestFlag1cd::s_id
, TestFlag2cd::s_id
);
131 cout
<< "1: " << TestFlag1cd::s_id
<< endl
;
132 cout
<< "2: " << TestFlag2cd::s_id
<< endl
;
134 lastId
= attr::LastAttributeId
<Node
, false>::getId();
135 // TS_ASSERT_LESS_THAN(theory::PreRewriteCache::s_id, lastId);
136 // TS_ASSERT_LESS_THAN(theory::PostRewriteCache::s_id, lastId);
137 // TS_ASSERT_LESS_THAN(theory::PreRewriteCacheTop::s_id, lastId);
138 // TS_ASSERT_LESS_THAN(theory::PostRewriteCacheTop::s_id, lastId);
139 // TS_ASSERT_DIFFERS(theory::PreRewriteCache::s_id, theory::PostRewriteCache::s_id);
140 // TS_ASSERT_DIFFERS(theory::PreRewriteCache::s_id, theory::PreRewriteCacheTop::s_id);
141 // TS_ASSERT_DIFFERS(theory::PreRewriteCache::s_id, theory::PostRewriteCacheTop::s_id);
142 // TS_ASSERT_DIFFERS(theory::PostRewriteCache::s_id, theory::PreRewriteCacheTop::s_id);
143 // TS_ASSERT_DIFFERS(theory::PostRewriteCache::s_id, theory::PostRewriteCacheTop::s_id);
144 // TS_ASSERT_DIFFERS(theory::PreRewriteCacheTop::s_id, theory::PostRewriteCacheTop::s_id);
146 lastId
= attr::LastAttributeId
<TypeNode
, false>::getId();
147 TS_ASSERT_LESS_THAN(TypeAttr::s_id
, lastId
);
151 void testCDAttributes() {
152 //Debug.on("cdboolattr");
154 Node a
= d_nm
->mkVar(*d_booleanType
);
155 Node b
= d_nm
->mkVar(*d_booleanType
);
156 Node c
= d_nm
->mkVar(*d_booleanType
);
158 Debug("cdboolattr") << "get flag 1 on a (should be F)\n";
159 TS_ASSERT(! a
.getAttribute(TestFlag1cd()));
160 Debug("cdboolattr") << "get flag 1 on b (should be F)\n";
161 TS_ASSERT(! b
.getAttribute(TestFlag1cd()));
162 Debug("cdboolattr") << "get flag 1 on c (should be F)\n";
163 TS_ASSERT(! c
.getAttribute(TestFlag1cd()));
165 d_ctxt
->push(); // level 1
167 // test that all boolean flags are FALSE to start
168 Debug("cdboolattr") << "get flag 1 on a (should be F)\n";
169 TS_ASSERT(! a
.getAttribute(TestFlag1cd()));
170 Debug("cdboolattr") << "get flag 1 on b (should be F)\n";
171 TS_ASSERT(! b
.getAttribute(TestFlag1cd()));
172 Debug("cdboolattr") << "get flag 1 on c (should be F)\n";
173 TS_ASSERT(! c
.getAttribute(TestFlag1cd()));
175 // test that they all HAVE the boolean attributes
176 TS_ASSERT(a
.hasAttribute(TestFlag1cd()));
177 TS_ASSERT(b
.hasAttribute(TestFlag1cd()));
178 TS_ASSERT(c
.hasAttribute(TestFlag1cd()));
180 // test two-arg version of hasAttribute()
182 Debug("cdboolattr") << "get flag 1 on a (should be F)\n";
183 TS_ASSERT(a
.getAttribute(TestFlag1cd(), bb
));
185 Debug("cdboolattr") << "get flag 1 on b (should be F)\n";
186 TS_ASSERT(b
.getAttribute(TestFlag1cd(), bb
));
188 Debug("cdboolattr") << "get flag 1 on c (should be F)\n";
189 TS_ASSERT(c
.getAttribute(TestFlag1cd(), bb
));
192 // setting boolean flags
193 Debug("cdboolattr") << "set flag 1 on a to T\n";
194 a
.setAttribute(TestFlag1cd(), true);
195 Debug("cdboolattr") << "set flag 1 on b to F\n";
196 b
.setAttribute(TestFlag1cd(), false);
197 Debug("cdboolattr") << "set flag 1 on c to F\n";
198 c
.setAttribute(TestFlag1cd(), false);
200 Debug("cdboolattr") << "get flag 1 on a (should be T)\n";
201 TS_ASSERT(a
.getAttribute(TestFlag1cd()));
202 Debug("cdboolattr") << "get flag 1 on b (should be F)\n";
203 TS_ASSERT(! b
.getAttribute(TestFlag1cd()));
204 Debug("cdboolattr") << "get flag 1 on c (should be F)\n";
205 TS_ASSERT(! c
.getAttribute(TestFlag1cd()));
207 d_ctxt
->push(); // level 2
209 Debug("cdboolattr") << "get flag 1 on a (should be T)\n";
210 TS_ASSERT(a
.getAttribute(TestFlag1cd()));
211 Debug("cdboolattr") << "get flag 1 on b (should be F)\n";
212 TS_ASSERT(! b
.getAttribute(TestFlag1cd()));
213 Debug("cdboolattr") << "get flag 1 on c (should be F)\n";
214 TS_ASSERT(! c
.getAttribute(TestFlag1cd()));
216 Debug("cdboolattr") << "set flag 1 on a to F\n";
217 a
.setAttribute(TestFlag1cd(), false);
218 Debug("cdboolattr") << "set flag 1 on b to T\n";
219 b
.setAttribute(TestFlag1cd(), true);
221 Debug("cdboolattr") << "get flag 1 on a (should be F)\n";
222 TS_ASSERT(! a
.getAttribute(TestFlag1cd()));
223 Debug("cdboolattr") << "get flag 1 on b (should be T)\n";
224 TS_ASSERT(b
.getAttribute(TestFlag1cd()));
225 Debug("cdboolattr") << "get flag 1 on c (should be F)\n";
226 TS_ASSERT(! c
.getAttribute(TestFlag1cd()));
228 d_ctxt
->push(); // level 3
230 Debug("cdboolattr") << "get flag 1 on a (should be F)\n";
231 TS_ASSERT(! a
.getAttribute(TestFlag1cd()));
232 Debug("cdboolattr") << "get flag 1 on b (should be T)\n";
233 TS_ASSERT(b
.getAttribute(TestFlag1cd()));
234 Debug("cdboolattr") << "get flag 1 on c (should be F)\n";
235 TS_ASSERT(! c
.getAttribute(TestFlag1cd()));
237 Debug("cdboolattr") << "set flag 1 on c to T\n";
238 c
.setAttribute(TestFlag1cd(), true);
240 Debug("cdboolattr") << "get flag 1 on a (should be F)\n";
241 TS_ASSERT(! a
.getAttribute(TestFlag1cd()));
242 Debug("cdboolattr") << "get flag 1 on b (should be T)\n";
243 TS_ASSERT(b
.getAttribute(TestFlag1cd()));
244 Debug("cdboolattr") << "get flag 1 on c (should be T)\n";
245 TS_ASSERT(c
.getAttribute(TestFlag1cd()));
247 d_ctxt
->pop(); // level 2
249 Debug("cdboolattr") << "get flag 1 on a (should be F)\n";
250 TS_ASSERT(! a
.getAttribute(TestFlag1cd()));
251 Debug("cdboolattr") << "get flag 1 on b (should be T)\n";
252 TS_ASSERT(b
.getAttribute(TestFlag1cd()));
253 Debug("cdboolattr") << "get flag 1 on c (should be F)\n";
254 TS_ASSERT(! c
.getAttribute(TestFlag1cd()));
256 d_ctxt
->pop(); // level 1
258 Debug("cdboolattr") << "get flag 1 on a (should be T)\n";
259 TS_ASSERT(a
.getAttribute(TestFlag1cd()));
260 Debug("cdboolattr") << "get flag 1 on b (should be F)\n";
261 TS_ASSERT(! b
.getAttribute(TestFlag1cd()));
262 Debug("cdboolattr") << "get flag 1 on c (should be F)\n";
263 TS_ASSERT(! c
.getAttribute(TestFlag1cd()));
265 d_ctxt
->pop(); // level 0
267 Debug("cdboolattr") << "get flag 1 on a (should be F)\n";
268 TS_ASSERT(! a
.getAttribute(TestFlag1cd()));
269 Debug("cdboolattr") << "get flag 1 on b (should be F)\n";
270 TS_ASSERT(! b
.getAttribute(TestFlag1cd()));
271 Debug("cdboolattr") << "get flag 1 on c (should be F)\n";
272 TS_ASSERT(! c
.getAttribute(TestFlag1cd()));
274 #ifdef CVC4_ASSERTIONS
275 TS_ASSERT_THROWS( d_ctxt
->pop(), AssertionException
);
276 #endif /* CVC4_ASSERTIONS */
279 void testAttributes() {
280 //Debug.on("bootattr");
282 Node a
= d_nm
->mkVar(*d_booleanType
);
283 Node b
= d_nm
->mkVar(*d_booleanType
);
284 Node c
= d_nm
->mkVar(*d_booleanType
);
285 Node unnamed
= d_nm
->mkVar(*d_booleanType
);
287 a
.setAttribute(VarNameAttr(), "a");
288 b
.setAttribute(VarNameAttr(), "b");
289 c
.setAttribute(VarNameAttr(), "c");
291 // test that all boolean flags are FALSE to start
292 Debug("boolattr") << "get flag 1 on a (should be F)\n";
293 TS_ASSERT(! a
.getAttribute(TestFlag1()));
294 Debug("boolattr") << "get flag 1 on b (should be F)\n";
295 TS_ASSERT(! b
.getAttribute(TestFlag1()));
296 Debug("boolattr") << "get flag 1 on c (should be F)\n";
297 TS_ASSERT(! c
.getAttribute(TestFlag1()));
298 Debug("boolattr") << "get flag 1 on unnamed (should be F)\n";
299 TS_ASSERT(! unnamed
.getAttribute(TestFlag1()));
301 Debug("boolattr") << "get flag 2 on a (should be F)\n";
302 TS_ASSERT(! a
.getAttribute(TestFlag2()));
303 Debug("boolattr") << "get flag 2 on b (should be F)\n";
304 TS_ASSERT(! b
.getAttribute(TestFlag2()));
305 Debug("boolattr") << "get flag 2 on c (should be F)\n";
306 TS_ASSERT(! c
.getAttribute(TestFlag2()));
307 Debug("boolattr") << "get flag 2 on unnamed (should be F)\n";
308 TS_ASSERT(! unnamed
.getAttribute(TestFlag2()));
310 Debug("boolattr") << "get flag 3 on a (should be F)\n";
311 TS_ASSERT(! a
.getAttribute(TestFlag3()));
312 Debug("boolattr") << "get flag 3 on b (should be F)\n";
313 TS_ASSERT(! b
.getAttribute(TestFlag3()));
314 Debug("boolattr") << "get flag 3 on c (should be F)\n";
315 TS_ASSERT(! c
.getAttribute(TestFlag3()));
316 Debug("boolattr") << "get flag 3 on unnamed (should be F)\n";
317 TS_ASSERT(! unnamed
.getAttribute(TestFlag3()));
319 Debug("boolattr") << "get flag 4 on a (should be F)\n";
320 TS_ASSERT(! a
.getAttribute(TestFlag4()));
321 Debug("boolattr") << "get flag 4 on b (should be F)\n";
322 TS_ASSERT(! b
.getAttribute(TestFlag4()));
323 Debug("boolattr") << "get flag 4 on c (should be F)\n";
324 TS_ASSERT(! c
.getAttribute(TestFlag4()));
325 Debug("boolattr") << "get flag 4 on unnamed (should be F)\n";
326 TS_ASSERT(! unnamed
.getAttribute(TestFlag4()));
328 Debug("boolattr") << "get flag 5 on a (should be F)\n";
329 TS_ASSERT(! a
.getAttribute(TestFlag5()));
330 Debug("boolattr") << "get flag 5 on b (should be F)\n";
331 TS_ASSERT(! b
.getAttribute(TestFlag5()));
332 Debug("boolattr") << "get flag 5 on c (should be F)\n";
333 TS_ASSERT(! c
.getAttribute(TestFlag5()));
334 Debug("boolattr") << "get flag 5 on unnamed (should be F)\n";
335 TS_ASSERT(! unnamed
.getAttribute(TestFlag5()));
337 // test that they all HAVE the boolean attributes
338 TS_ASSERT(a
.hasAttribute(TestFlag1()));
339 TS_ASSERT(b
.hasAttribute(TestFlag1()));
340 TS_ASSERT(c
.hasAttribute(TestFlag1()));
341 TS_ASSERT(unnamed
.hasAttribute(TestFlag1()));
343 TS_ASSERT(a
.hasAttribute(TestFlag2()));
344 TS_ASSERT(b
.hasAttribute(TestFlag2()));
345 TS_ASSERT(c
.hasAttribute(TestFlag2()));
346 TS_ASSERT(unnamed
.hasAttribute(TestFlag2()));
348 TS_ASSERT(a
.hasAttribute(TestFlag3()));
349 TS_ASSERT(b
.hasAttribute(TestFlag3()));
350 TS_ASSERT(c
.hasAttribute(TestFlag3()));
351 TS_ASSERT(unnamed
.hasAttribute(TestFlag3()));
353 TS_ASSERT(a
.hasAttribute(TestFlag4()));
354 TS_ASSERT(b
.hasAttribute(TestFlag4()));
355 TS_ASSERT(c
.hasAttribute(TestFlag4()));
356 TS_ASSERT(unnamed
.hasAttribute(TestFlag4()));
358 TS_ASSERT(a
.hasAttribute(TestFlag5()));
359 TS_ASSERT(b
.hasAttribute(TestFlag5()));
360 TS_ASSERT(c
.hasAttribute(TestFlag5()));
361 TS_ASSERT(unnamed
.hasAttribute(TestFlag5()));
363 // test two-arg version of hasAttribute()
365 Debug("boolattr") << "get flag 1 on a (should be F)\n";
366 TS_ASSERT(a
.getAttribute(TestFlag1(), bb
));
368 Debug("boolattr") << "get flag 1 on b (should be F)\n";
369 TS_ASSERT(b
.getAttribute(TestFlag1(), bb
));
371 Debug("boolattr") << "get flag 1 on c (should be F)\n";
372 TS_ASSERT(c
.getAttribute(TestFlag1(), bb
));
374 Debug("boolattr") << "get flag 1 on unnamed (should be F)\n";
375 TS_ASSERT(unnamed
.getAttribute(TestFlag1(), bb
));
378 Debug("boolattr") << "get flag 2 on a (should be F)\n";
379 TS_ASSERT(a
.getAttribute(TestFlag2(), bb
));
381 Debug("boolattr") << "get flag 2 on b (should be F)\n";
382 TS_ASSERT(b
.getAttribute(TestFlag2(), bb
));
384 Debug("boolattr") << "get flag 2 on c (should be F)\n";
385 TS_ASSERT(c
.getAttribute(TestFlag2(), bb
));
387 Debug("boolattr") << "get flag 2 on unnamed (should be F)\n";
388 TS_ASSERT(unnamed
.getAttribute(TestFlag2(), bb
));
391 Debug("boolattr") << "get flag 3 on a (should be F)\n";
392 TS_ASSERT(a
.getAttribute(TestFlag3(), bb
));
394 Debug("boolattr") << "get flag 3 on b (should be F)\n";
395 TS_ASSERT(b
.getAttribute(TestFlag3(), bb
));
397 Debug("boolattr") << "get flag 3 on c (should be F)\n";
398 TS_ASSERT(c
.getAttribute(TestFlag3(), bb
));
400 Debug("boolattr") << "get flag 3 on unnamed (should be F)\n";
401 TS_ASSERT(unnamed
.getAttribute(TestFlag3(), bb
));
404 Debug("boolattr") << "get flag 4 on a (should be F)\n";
405 TS_ASSERT(a
.getAttribute(TestFlag4(), bb
));
407 Debug("boolattr") << "get flag 4 on b (should be F)\n";
408 TS_ASSERT(b
.getAttribute(TestFlag4(), bb
));
410 Debug("boolattr") << "get flag 4 on c (should be F)\n";
411 TS_ASSERT(c
.getAttribute(TestFlag4(), bb
));
413 Debug("boolattr") << "get flag 4 on unnamed (should be F)\n";
414 TS_ASSERT(unnamed
.getAttribute(TestFlag4(), bb
));
417 Debug("boolattr") << "get flag 5 on a (should be F)\n";
418 TS_ASSERT(a
.getAttribute(TestFlag5(), bb
));
420 Debug("boolattr") << "get flag 5 on b (should be F)\n";
421 TS_ASSERT(b
.getAttribute(TestFlag5(), bb
));
423 Debug("boolattr") << "get flag 5 on c (should be F)\n";
424 TS_ASSERT(c
.getAttribute(TestFlag5(), bb
));
426 Debug("boolattr") << "get flag 5 on unnamed (should be F)\n";
427 TS_ASSERT(unnamed
.getAttribute(TestFlag5(), bb
));
430 // setting boolean flags
431 Debug("boolattr") << "set flag 1 on a to T\n";
432 a
.setAttribute(TestFlag1(), true);
433 Debug("boolattr") << "set flag 1 on b to F\n";
434 b
.setAttribute(TestFlag1(), false);
435 Debug("boolattr") << "set flag 1 on c to F\n";
436 c
.setAttribute(TestFlag1(), false);
437 Debug("boolattr") << "set flag 1 on unnamed to T\n";
438 unnamed
.setAttribute(TestFlag1(), true);
440 Debug("boolattr") << "set flag 2 on a to F\n";
441 a
.setAttribute(TestFlag2(), false);
442 Debug("boolattr") << "set flag 2 on b to T\n";
443 b
.setAttribute(TestFlag2(), true);
444 Debug("boolattr") << "set flag 2 on c to T\n";
445 c
.setAttribute(TestFlag2(), true);
446 Debug("boolattr") << "set flag 2 on unnamed to F\n";
447 unnamed
.setAttribute(TestFlag2(), false);
449 Debug("boolattr") << "set flag 3 on a to T\n";
450 a
.setAttribute(TestFlag3(), true);
451 Debug("boolattr") << "set flag 3 on b to T\n";
452 b
.setAttribute(TestFlag3(), true);
453 Debug("boolattr") << "set flag 3 on c to T\n";
454 c
.setAttribute(TestFlag3(), true);
455 Debug("boolattr") << "set flag 3 on unnamed to T\n";
456 unnamed
.setAttribute(TestFlag3(), true);
458 Debug("boolattr") << "set flag 4 on a to T\n";
459 a
.setAttribute(TestFlag4(), true);
460 Debug("boolattr") << "set flag 4 on b to T\n";
461 b
.setAttribute(TestFlag4(), true);
462 Debug("boolattr") << "set flag 4 on c to T\n";
463 c
.setAttribute(TestFlag4(), true);
464 Debug("boolattr") << "set flag 4 on unnamed to T\n";
465 unnamed
.setAttribute(TestFlag4(), true);
467 Debug("boolattr") << "set flag 5 on a to T\n";
468 a
.setAttribute(TestFlag5(), true);
469 Debug("boolattr") << "set flag 5 on b to T\n";
470 b
.setAttribute(TestFlag5(), true);
471 Debug("boolattr") << "set flag 5 on c to F\n";
472 c
.setAttribute(TestFlag5(), false);
473 Debug("boolattr") << "set flag 5 on unnamed to T\n";
474 unnamed
.setAttribute(TestFlag5(), true);
476 TS_ASSERT(a
.getAttribute(VarNameAttr()) == "a");
477 TS_ASSERT(a
.getAttribute(VarNameAttr()) != "b");
478 TS_ASSERT(a
.getAttribute(VarNameAttr()) != "c");
479 TS_ASSERT(a
.getAttribute(VarNameAttr()) != "");
481 TS_ASSERT(b
.getAttribute(VarNameAttr()) != "a");
482 TS_ASSERT(b
.getAttribute(VarNameAttr()) == "b");
483 TS_ASSERT(b
.getAttribute(VarNameAttr()) != "c");
484 TS_ASSERT(b
.getAttribute(VarNameAttr()) != "");
486 TS_ASSERT(c
.getAttribute(VarNameAttr()) != "a");
487 TS_ASSERT(c
.getAttribute(VarNameAttr()) != "b");
488 TS_ASSERT(c
.getAttribute(VarNameAttr()) == "c");
489 TS_ASSERT(c
.getAttribute(VarNameAttr()) != "");
491 TS_ASSERT(unnamed
.getAttribute(VarNameAttr()) != "a");
492 TS_ASSERT(unnamed
.getAttribute(VarNameAttr()) != "b");
493 TS_ASSERT(unnamed
.getAttribute(VarNameAttr()) != "c");
494 TS_ASSERT(unnamed
.getAttribute(VarNameAttr()) == "");
496 TS_ASSERT(! unnamed
.hasAttribute(VarNameAttr()));
498 TS_ASSERT(! a
.hasAttribute(TestStringAttr1()));
499 TS_ASSERT(! b
.hasAttribute(TestStringAttr1()));
500 TS_ASSERT(! c
.hasAttribute(TestStringAttr1()));
501 TS_ASSERT(! unnamed
.hasAttribute(TestStringAttr1()));
503 TS_ASSERT(! a
.hasAttribute(TestStringAttr2()));
504 TS_ASSERT(! b
.hasAttribute(TestStringAttr2()));
505 TS_ASSERT(! c
.hasAttribute(TestStringAttr2()));
506 TS_ASSERT(! unnamed
.hasAttribute(TestStringAttr2()));
508 Debug("boolattr") << "get flag 1 on a (should be T)\n";
509 TS_ASSERT(a
.getAttribute(TestFlag1()));
510 Debug("boolattr") << "get flag 1 on b (should be F)\n";
511 TS_ASSERT(! b
.getAttribute(TestFlag1()));
512 Debug("boolattr") << "get flag 1 on c (should be F)\n";
513 TS_ASSERT(! c
.getAttribute(TestFlag1()));
514 Debug("boolattr") << "get flag 1 on unnamed (should be T)\n";
515 TS_ASSERT(unnamed
.getAttribute(TestFlag1()));
517 Debug("boolattr") << "get flag 2 on a (should be F)\n";
518 TS_ASSERT(! a
.getAttribute(TestFlag2()));
519 Debug("boolattr") << "get flag 2 on b (should be T)\n";
520 TS_ASSERT(b
.getAttribute(TestFlag2()));
521 Debug("boolattr") << "get flag 2 on c (should be T)\n";
522 TS_ASSERT(c
.getAttribute(TestFlag2()));
523 Debug("boolattr") << "get flag 2 on unnamed (should be F)\n";
524 TS_ASSERT(! unnamed
.getAttribute(TestFlag2()));
526 Debug("boolattr") << "get flag 3 on a (should be T)\n";
527 TS_ASSERT(a
.getAttribute(TestFlag3()));
528 Debug("boolattr") << "get flag 3 on b (should be T)\n";
529 TS_ASSERT(b
.getAttribute(TestFlag3()));
530 Debug("boolattr") << "get flag 3 on c (should be T)\n";
531 TS_ASSERT(c
.getAttribute(TestFlag3()));
532 Debug("boolattr") << "get flag 3 on unnamed (should be T)\n";
533 TS_ASSERT(unnamed
.getAttribute(TestFlag3()));
535 Debug("boolattr") << "get flag 4 on a (should be T)\n";
536 TS_ASSERT(a
.getAttribute(TestFlag4()));
537 Debug("boolattr") << "get flag 4 on b (should be T)\n";
538 TS_ASSERT(b
.getAttribute(TestFlag4()));
539 Debug("boolattr") << "get flag 4 on c (should be T)\n";
540 TS_ASSERT(c
.getAttribute(TestFlag4()));
541 Debug("boolattr") << "get flag 4 on unnamed (should be T)\n";
542 TS_ASSERT(unnamed
.getAttribute(TestFlag4()));
544 Debug("boolattr") << "get flag 5 on a (should be T)\n";
545 TS_ASSERT(a
.getAttribute(TestFlag5()));
546 Debug("boolattr") << "get flag 5 on b (should be T)\n";
547 TS_ASSERT(b
.getAttribute(TestFlag5()));
548 Debug("boolattr") << "get flag 5 on c (should be F)\n";
549 TS_ASSERT(! c
.getAttribute(TestFlag5()));
550 Debug("boolattr") << "get flag 5 on unnamed (should be T)\n";
551 TS_ASSERT(unnamed
.getAttribute(TestFlag5()));
553 a
.setAttribute(TestStringAttr1(), "foo");
554 b
.setAttribute(TestStringAttr1(), "bar");
555 c
.setAttribute(TestStringAttr1(), "baz");
557 TS_ASSERT(a
.getAttribute(VarNameAttr()) == "a");
558 TS_ASSERT(a
.getAttribute(VarNameAttr()) != "b");
559 TS_ASSERT(a
.getAttribute(VarNameAttr()) != "c");
560 TS_ASSERT(a
.getAttribute(VarNameAttr()) != "");
562 TS_ASSERT(b
.getAttribute(VarNameAttr()) != "a");
563 TS_ASSERT(b
.getAttribute(VarNameAttr()) == "b");
564 TS_ASSERT(b
.getAttribute(VarNameAttr()) != "c");
565 TS_ASSERT(b
.getAttribute(VarNameAttr()) != "");
567 TS_ASSERT(c
.getAttribute(VarNameAttr()) != "a");
568 TS_ASSERT(c
.getAttribute(VarNameAttr()) != "b");
569 TS_ASSERT(c
.getAttribute(VarNameAttr()) == "c");
570 TS_ASSERT(c
.getAttribute(VarNameAttr()) != "");
572 TS_ASSERT(unnamed
.getAttribute(VarNameAttr()) != "a");
573 TS_ASSERT(unnamed
.getAttribute(VarNameAttr()) != "b");
574 TS_ASSERT(unnamed
.getAttribute(VarNameAttr()) != "c");
575 TS_ASSERT(unnamed
.getAttribute(VarNameAttr()) == "");
577 TS_ASSERT(! unnamed
.hasAttribute(VarNameAttr()));
579 TS_ASSERT(a
.hasAttribute(TestStringAttr1()));
580 TS_ASSERT(b
.hasAttribute(TestStringAttr1()));
581 TS_ASSERT(c
.hasAttribute(TestStringAttr1()));
582 TS_ASSERT(! unnamed
.hasAttribute(TestStringAttr1()));
584 TS_ASSERT(! a
.hasAttribute(TestStringAttr2()));
585 TS_ASSERT(! b
.hasAttribute(TestStringAttr2()));
586 TS_ASSERT(! c
.hasAttribute(TestStringAttr2()));
587 TS_ASSERT(! unnamed
.hasAttribute(TestStringAttr2()));
589 a
.setAttribute(VarNameAttr(), "b");
590 b
.setAttribute(VarNameAttr(), "c");
591 c
.setAttribute(VarNameAttr(), "a");
593 TS_ASSERT(c
.getAttribute(VarNameAttr()) == "a");
594 TS_ASSERT(c
.getAttribute(VarNameAttr()) != "b");
595 TS_ASSERT(c
.getAttribute(VarNameAttr()) != "c");
596 TS_ASSERT(c
.getAttribute(VarNameAttr()) != "");
598 TS_ASSERT(a
.getAttribute(VarNameAttr()) != "a");
599 TS_ASSERT(a
.getAttribute(VarNameAttr()) == "b");
600 TS_ASSERT(a
.getAttribute(VarNameAttr()) != "c");
601 TS_ASSERT(a
.getAttribute(VarNameAttr()) != "");
603 TS_ASSERT(b
.getAttribute(VarNameAttr()) != "a");
604 TS_ASSERT(b
.getAttribute(VarNameAttr()) != "b");
605 TS_ASSERT(b
.getAttribute(VarNameAttr()) == "c");
606 TS_ASSERT(b
.getAttribute(VarNameAttr()) != "");
608 TS_ASSERT(unnamed
.getAttribute(VarNameAttr()) != "a");
609 TS_ASSERT(unnamed
.getAttribute(VarNameAttr()) != "b");
610 TS_ASSERT(unnamed
.getAttribute(VarNameAttr()) != "c");
611 TS_ASSERT(unnamed
.getAttribute(VarNameAttr()) == "");
613 TS_ASSERT(! unnamed
.hasAttribute(VarNameAttr()));