summaryrefslogtreecommitdiff
path: root/test/unit/expr/attribute_white.h
blob: 7fa9972a6893b60f3bd05cced6a2b5846a1fb72e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
/*********************                                                        */
/*! \file attribute_white.h
 ** \verbatim
 ** Original author: Morgan Deters
 ** Major contributors: none
 ** Minor contributors (to current version): Dejan Jovanovic, Christopher L. Conway
 ** This file is part of the CVC4 project.
 ** Copyright (c) 2009-2013  New York University and The University of Iowa
 ** See the file COPYING in the top-level source directory for licensing
 ** information.\endverbatim
 **
 ** \brief White box testing of Node attributes.
 **
 ** White box testing of Node attributes.
 **/

#include <cxxtest/TestSuite.h>

#include <string>

#include "context/context.h"
#include "expr/node_value.h"
#include "expr/node_builder.h"
#include "expr/node_manager.h"
#include "expr/attribute.h"
#include "expr/node_manager_attributes.h"
#include "expr/node.h"
#include "theory/theory.h"
#include "theory/theory_engine.h"
#include "theory/uf/theory_uf.h"
#include "util/cvc4_assert.h"

using namespace CVC4;
using namespace CVC4::kind;
using namespace CVC4::context;
using namespace CVC4::expr;
using namespace CVC4::expr::attr;
using namespace std;

struct Test1;
struct Test2;
struct Test3;
struct Test4;
struct Test5;

typedef Attribute<Test1, std::string> TestStringAttr1;
typedef Attribute<Test2, std::string> TestStringAttr2;

// it would be nice to have CDAttribute<> for context-dependence
typedef CDAttribute<Test1, bool> TestCDFlag;

typedef Attribute<Test1, bool> TestFlag1;
typedef Attribute<Test2, bool> TestFlag2;
typedef Attribute<Test3, bool> TestFlag3;
typedef Attribute<Test4, bool> TestFlag4;
typedef Attribute<Test5, bool> TestFlag5;

typedef CDAttribute<Test1, bool> TestFlag1cd;
typedef CDAttribute<Test2, bool> TestFlag2cd;

class AttributeWhite : public CxxTest::TestSuite {

  Context* d_ctxt;
  NodeManager* d_nm;
  NodeManagerScope* d_scope;
  TypeNode* d_booleanType;

public:

  void setUp() {
    d_ctxt = new Context;
    d_nm = new NodeManager(d_ctxt, NULL);
    d_scope = new NodeManagerScope(d_nm);

    d_booleanType = new TypeNode(d_nm->booleanType());
  }

  void tearDown() {
    delete d_booleanType;
    delete d_scope;
    delete d_nm;
    delete d_ctxt;
  }

  void testAttributeIds() {
    // Test that IDs for (a subset of) attributes in the system are
    // unique and that the LastAttributeId (which would be the next ID
    // to assign) is greater than all attribute IDs.

    // We used to check ID assignments explicitly.  However, between
    // compilation modules, you don't get a strong guarantee
    // (initialization order is somewhat implementation-specific, and
    // anyway you'd have to change the tests anytime you add an
    // attribute).  So we back off, and just test that they're unique
    // and that the next ID to be assigned is strictly greater than
    // those that have already been assigned.

    unsigned lastId = attr::LastAttributeId<string, false>::getId();
    TS_ASSERT_LESS_THAN(VarNameAttr::s_id, lastId);
    TS_ASSERT_LESS_THAN(TestStringAttr1::s_id, lastId);
    TS_ASSERT_LESS_THAN(TestStringAttr2::s_id, lastId);

    TS_ASSERT_DIFFERS(VarNameAttr::s_id, TestStringAttr1::s_id);
    TS_ASSERT_DIFFERS(VarNameAttr::s_id, TestStringAttr2::s_id);
    TS_ASSERT_DIFFERS(TestStringAttr1::s_id, TestStringAttr2::s_id);

    //lastId = attr::LastAttributeId<void*, false>::getId();
    //TS_ASSERT_LESS_THAN(theory::uf::ECAttr::s_id, lastId);

    lastId = attr::LastAttributeId<bool, false>::getId();
    TS_ASSERT_LESS_THAN(TestFlag1::s_id, lastId);
    TS_ASSERT_LESS_THAN(TestFlag2::s_id, lastId);
    TS_ASSERT_LESS_THAN(TestFlag3::s_id, lastId);
    TS_ASSERT_LESS_THAN(TestFlag4::s_id, lastId);
    TS_ASSERT_LESS_THAN(TestFlag5::s_id, lastId);
    TS_ASSERT_DIFFERS(TestFlag1::s_id, TestFlag2::s_id);
    TS_ASSERT_DIFFERS(TestFlag1::s_id, TestFlag3::s_id);
    TS_ASSERT_DIFFERS(TestFlag1::s_id, TestFlag4::s_id);
    TS_ASSERT_DIFFERS(TestFlag1::s_id, TestFlag5::s_id);
    TS_ASSERT_DIFFERS(TestFlag2::s_id, TestFlag3::s_id);
    TS_ASSERT_DIFFERS(TestFlag2::s_id, TestFlag4::s_id);
    TS_ASSERT_DIFFERS(TestFlag2::s_id, TestFlag5::s_id);
    TS_ASSERT_DIFFERS(TestFlag3::s_id, TestFlag4::s_id);
    TS_ASSERT_DIFFERS(TestFlag3::s_id, TestFlag5::s_id);
    TS_ASSERT_DIFFERS(TestFlag4::s_id, TestFlag5::s_id);

    lastId = attr::LastAttributeId<bool, true>::getId();
    TS_ASSERT_LESS_THAN(TestFlag1cd::s_id, lastId);
    TS_ASSERT_LESS_THAN(TestFlag2cd::s_id, lastId);
    TS_ASSERT_DIFFERS(TestFlag1cd::s_id, TestFlag2cd::s_id);
    cout << "1: " << TestFlag1cd::s_id << endl;
    cout << "2: " << TestFlag2cd::s_id << endl;

    lastId = attr::LastAttributeId<Node, false>::getId();
//    TS_ASSERT_LESS_THAN(theory::PreRewriteCache::s_id, lastId);
//    TS_ASSERT_LESS_THAN(theory::PostRewriteCache::s_id, lastId);
//    TS_ASSERT_LESS_THAN(theory::PreRewriteCacheTop::s_id, lastId);
//    TS_ASSERT_LESS_THAN(theory::PostRewriteCacheTop::s_id, lastId);
//    TS_ASSERT_DIFFERS(theory::PreRewriteCache::s_id, theory::PostRewriteCache::s_id);
//    TS_ASSERT_DIFFERS(theory::PreRewriteCache::s_id, theory::PreRewriteCacheTop::s_id);
//    TS_ASSERT_DIFFERS(theory::PreRewriteCache::s_id, theory::PostRewriteCacheTop::s_id);
//    TS_ASSERT_DIFFERS(theory::PostRewriteCache::s_id, theory::PreRewriteCacheTop::s_id);
//    TS_ASSERT_DIFFERS(theory::PostRewriteCache::s_id, theory::PostRewriteCacheTop::s_id);
//    TS_ASSERT_DIFFERS(theory::PreRewriteCacheTop::s_id, theory::PostRewriteCacheTop::s_id);

    lastId = attr::LastAttributeId<TypeNode, false>::getId();
    TS_ASSERT_LESS_THAN(TypeAttr::s_id, lastId);

  }

  void testCDAttributes() {
    //Debug.on("cdboolattr");

    Node a = d_nm->mkVar(*d_booleanType);
    Node b = d_nm->mkVar(*d_booleanType);
    Node c = d_nm->mkVar(*d_booleanType);

    Debug("cdboolattr") << "get flag 1 on a (should be F)\n";
    TS_ASSERT(! a.getAttribute(TestFlag1cd()));
    Debug("cdboolattr") << "get flag 1 on b (should be F)\n";
    TS_ASSERT(! b.getAttribute(TestFlag1cd()));
    Debug("cdboolattr") << "get flag 1 on c (should be F)\n";
    TS_ASSERT(! c.getAttribute(TestFlag1cd()));

    d_ctxt->push(); // level 1

    // test that all boolean flags are FALSE to start
    Debug("cdboolattr") << "get flag 1 on a (should be F)\n";
    TS_ASSERT(! a.getAttribute(TestFlag1cd()));
    Debug("cdboolattr") << "get flag 1 on b (should be F)\n";
    TS_ASSERT(! b.getAttribute(TestFlag1cd()));
    Debug("cdboolattr") << "get flag 1 on c (should be F)\n";
    TS_ASSERT(! c.getAttribute(TestFlag1cd()));

    // test that they all HAVE the boolean attributes
    TS_ASSERT(a.hasAttribute(TestFlag1cd()));
    TS_ASSERT(b.hasAttribute(TestFlag1cd()));
    TS_ASSERT(c.hasAttribute(TestFlag1cd()));

    // test two-arg version of hasAttribute()
    bool bb = false;
    Debug("cdboolattr") << "get flag 1 on a (should be F)\n";
    TS_ASSERT(a.getAttribute(TestFlag1cd(), bb));
    TS_ASSERT(! bb);
    Debug("cdboolattr") << "get flag 1 on b (should be F)\n";
    TS_ASSERT(b.getAttribute(TestFlag1cd(), bb));
    TS_ASSERT(! bb);
    Debug("cdboolattr") << "get flag 1 on c (should be F)\n";
    TS_ASSERT(c.getAttribute(TestFlag1cd(), bb));
    TS_ASSERT(! bb);

    // setting boolean flags
    Debug("cdboolattr") << "set flag 1 on a to T\n";
    a.setAttribute(TestFlag1cd(), true);
    Debug("cdboolattr") << "set flag 1 on b to F\n";
    b.setAttribute(TestFlag1cd(), false);
    Debug("cdboolattr") << "set flag 1 on c to F\n";
    c.setAttribute(TestFlag1cd(), false);

    Debug("cdboolattr") << "get flag 1 on a (should be T)\n";
    TS_ASSERT(a.getAttribute(TestFlag1cd()));
    Debug("cdboolattr") << "get flag 1 on b (should be F)\n";
    TS_ASSERT(! b.getAttribute(TestFlag1cd()));
    Debug("cdboolattr") << "get flag 1 on c (should be F)\n";
    TS_ASSERT(! c.getAttribute(TestFlag1cd()));

    d_ctxt->push(); // level 2

    Debug("cdboolattr") << "get flag 1 on a (should be T)\n";
    TS_ASSERT(a.getAttribute(TestFlag1cd()));
    Debug("cdboolattr") << "get flag 1 on b (should be F)\n";
    TS_ASSERT(! b.getAttribute(TestFlag1cd()));
    Debug("cdboolattr") << "get flag 1 on c (should be F)\n";
    TS_ASSERT(! c.getAttribute(TestFlag1cd()));

    Debug("cdboolattr") << "set flag 1 on a to F\n";
    a.setAttribute(TestFlag1cd(), false);
    Debug("cdboolattr") << "set flag 1 on b to T\n";
    b.setAttribute(TestFlag1cd(), true);

    Debug("cdboolattr") << "get flag 1 on a (should be F)\n";
    TS_ASSERT(! a.getAttribute(TestFlag1cd()));
    Debug("cdboolattr") << "get flag 1 on b (should be T)\n";
    TS_ASSERT(b.getAttribute(TestFlag1cd()));
    Debug("cdboolattr") << "get flag 1 on c (should be F)\n";
    TS_ASSERT(! c.getAttribute(TestFlag1cd()));

    d_ctxt->push(); // level 3

    Debug("cdboolattr") << "get flag 1 on a (should be F)\n";
    TS_ASSERT(! a.getAttribute(TestFlag1cd()));
    Debug("cdboolattr") << "get flag 1 on b (should be T)\n";
    TS_ASSERT(b.getAttribute(TestFlag1cd()));
    Debug("cdboolattr") << "get flag 1 on c (should be F)\n";
    TS_ASSERT(! c.getAttribute(TestFlag1cd()));

    Debug("cdboolattr") << "set flag 1 on c to T\n";
    c.setAttribute(TestFlag1cd(), true);

    Debug("cdboolattr") << "get flag 1 on a (should be F)\n";
    TS_ASSERT(! a.getAttribute(TestFlag1cd()));
    Debug("cdboolattr") << "get flag 1 on b (should be T)\n";
    TS_ASSERT(b.getAttribute(TestFlag1cd()));
    Debug("cdboolattr") << "get flag 1 on c (should be T)\n";
    TS_ASSERT(c.getAttribute(TestFlag1cd()));

    d_ctxt->pop(); // level 2

    Debug("cdboolattr") << "get flag 1 on a (should be F)\n";
    TS_ASSERT(! a.getAttribute(TestFlag1cd()));
    Debug("cdboolattr") << "get flag 1 on b (should be T)\n";
    TS_ASSERT(b.getAttribute(TestFlag1cd()));
    Debug("cdboolattr") << "get flag 1 on c (should be F)\n";
    TS_ASSERT(! c.getAttribute(TestFlag1cd()));

    d_ctxt->pop(); // level 1

    Debug("cdboolattr") << "get flag 1 on a (should be T)\n";
    TS_ASSERT(a.getAttribute(TestFlag1cd()));
    Debug("cdboolattr") << "get flag 1 on b (should be F)\n";
    TS_ASSERT(! b.getAttribute(TestFlag1cd()));
    Debug("cdboolattr") << "get flag 1 on c (should be F)\n";
    TS_ASSERT(! c.getAttribute(TestFlag1cd()));

    d_ctxt->pop(); // level 0

    Debug("cdboolattr") << "get flag 1 on a (should be F)\n";
    TS_ASSERT(! a.getAttribute(TestFlag1cd()));
    Debug("cdboolattr") << "get flag 1 on b (should be F)\n";
    TS_ASSERT(! b.getAttribute(TestFlag1cd()));
    Debug("cdboolattr") << "get flag 1 on c (should be F)\n";
    TS_ASSERT(! c.getAttribute(TestFlag1cd()));

#ifdef CVC4_ASSERTIONS
    TS_ASSERT_THROWS( d_ctxt->pop(), AssertionException );
#endif /* CVC4_ASSERTIONS */
  }

  void testAttributes() {
    //Debug.on("bootattr");

    Node a = d_nm->mkVar(*d_booleanType);
    Node b = d_nm->mkVar(*d_booleanType);
    Node c = d_nm->mkVar(*d_booleanType);
    Node unnamed = d_nm->mkVar(*d_booleanType);

    a.setAttribute(VarNameAttr(), "a");
    b.setAttribute(VarNameAttr(), "b");
    c.setAttribute(VarNameAttr(), "c");

    // test that all boolean flags are FALSE to start
    Debug("boolattr") << "get flag 1 on a (should be F)\n";
    TS_ASSERT(! a.getAttribute(TestFlag1()));
    Debug("boolattr") << "get flag 1 on b (should be F)\n";
    TS_ASSERT(! b.getAttribute(TestFlag1()));
    Debug("boolattr") << "get flag 1 on c (should be F)\n";
    TS_ASSERT(! c.getAttribute(TestFlag1()));
    Debug("boolattr") << "get flag 1 on unnamed (should be F)\n";
    TS_ASSERT(! unnamed.getAttribute(TestFlag1()));

    Debug("boolattr") << "get flag 2 on a (should be F)\n";
    TS_ASSERT(! a.getAttribute(TestFlag2()));
    Debug("boolattr") << "get flag 2 on b (should be F)\n";
    TS_ASSERT(! b.getAttribute(TestFlag2()));
    Debug("boolattr") << "get flag 2 on c (should be F)\n";
    TS_ASSERT(! c.getAttribute(TestFlag2()));
    Debug("boolattr") << "get flag 2 on unnamed (should be F)\n";
    TS_ASSERT(! unnamed.getAttribute(TestFlag2()));

    Debug("boolattr") << "get flag 3 on a (should be F)\n";
    TS_ASSERT(! a.getAttribute(TestFlag3()));
    Debug("boolattr") << "get flag 3 on b (should be F)\n";
    TS_ASSERT(! b.getAttribute(TestFlag3()));
    Debug("boolattr") << "get flag 3 on c (should be F)\n";
    TS_ASSERT(! c.getAttribute(TestFlag3()));
    Debug("boolattr") << "get flag 3 on unnamed (should be F)\n";
    TS_ASSERT(! unnamed.getAttribute(TestFlag3()));

    Debug("boolattr") << "get flag 4 on a (should be F)\n";
    TS_ASSERT(! a.getAttribute(TestFlag4()));
    Debug("boolattr") << "get flag 4 on b (should be F)\n";
    TS_ASSERT(! b.getAttribute(TestFlag4()));
    Debug("boolattr") << "get flag 4 on c (should be F)\n";
    TS_ASSERT(! c.getAttribute(TestFlag4()));
    Debug("boolattr") << "get flag 4 on unnamed (should be F)\n";
    TS_ASSERT(! unnamed.getAttribute(TestFlag4()));

    Debug("boolattr") << "get flag 5 on a (should be F)\n";
    TS_ASSERT(! a.getAttribute(TestFlag5()));
    Debug("boolattr") << "get flag 5 on b (should be F)\n";
    TS_ASSERT(! b.getAttribute(TestFlag5()));
    Debug("boolattr") << "get flag 5 on c (should be F)\n";
    TS_ASSERT(! c.getAttribute(TestFlag5()));
    Debug("boolattr") << "get flag 5 on unnamed (should be F)\n";
    TS_ASSERT(! unnamed.getAttribute(TestFlag5()));

    // test that they all HAVE the boolean attributes
    TS_ASSERT(a.hasAttribute(TestFlag1()));
    TS_ASSERT(b.hasAttribute(TestFlag1()));
    TS_ASSERT(c.hasAttribute(TestFlag1()));
    TS_ASSERT(unnamed.hasAttribute(TestFlag1()));

    TS_ASSERT(a.hasAttribute(TestFlag2()));
    TS_ASSERT(b.hasAttribute(TestFlag2()));
    TS_ASSERT(c.hasAttribute(TestFlag2()));
    TS_ASSERT(unnamed.hasAttribute(TestFlag2()));

    TS_ASSERT(a.hasAttribute(TestFlag3()));
    TS_ASSERT(b.hasAttribute(TestFlag3()));
    TS_ASSERT(c.hasAttribute(TestFlag3()));
    TS_ASSERT(unnamed.hasAttribute(TestFlag3()));

    TS_ASSERT(a.hasAttribute(TestFlag4()));
    TS_ASSERT(b.hasAttribute(TestFlag4()));
    TS_ASSERT(c.hasAttribute(TestFlag4()));
    TS_ASSERT(unnamed.hasAttribute(TestFlag4()));

    TS_ASSERT(a.hasAttribute(TestFlag5()));
    TS_ASSERT(b.hasAttribute(TestFlag5()));
    TS_ASSERT(c.hasAttribute(TestFlag5()));
    TS_ASSERT(unnamed.hasAttribute(TestFlag5()));

    // test two-arg version of hasAttribute()
    bool bb = false;
    Debug("boolattr") << "get flag 1 on a (should be F)\n";
    TS_ASSERT(a.getAttribute(TestFlag1(), bb));
    TS_ASSERT(! bb);
    Debug("boolattr") << "get flag 1 on b (should be F)\n";
    TS_ASSERT(b.getAttribute(TestFlag1(), bb));
    TS_ASSERT(! bb);
    Debug("boolattr") << "get flag 1 on c (should be F)\n";
    TS_ASSERT(c.getAttribute(TestFlag1(), bb));
    TS_ASSERT(! bb);
    Debug("boolattr") << "get flag 1 on unnamed (should be F)\n";
    TS_ASSERT(unnamed.getAttribute(TestFlag1(), bb));
    TS_ASSERT(! bb);

    Debug("boolattr") << "get flag 2 on a (should be F)\n";
    TS_ASSERT(a.getAttribute(TestFlag2(), bb));
    TS_ASSERT(! bb);
    Debug("boolattr") << "get flag 2 on b (should be F)\n";
    TS_ASSERT(b.getAttribute(TestFlag2(), bb));
    TS_ASSERT(! bb);
    Debug("boolattr") << "get flag 2 on c (should be F)\n";
    TS_ASSERT(c.getAttribute(TestFlag2(), bb));
    TS_ASSERT(! bb);
    Debug("boolattr") << "get flag 2 on unnamed (should be F)\n";
    TS_ASSERT(unnamed.getAttribute(TestFlag2(), bb));
    TS_ASSERT(! bb);

    Debug("boolattr") << "get flag 3 on a (should be F)\n";
    TS_ASSERT(a.getAttribute(TestFlag3(), bb));
    TS_ASSERT(! bb);
    Debug("boolattr") << "get flag 3 on b (should be F)\n";
    TS_ASSERT(b.getAttribute(TestFlag3(), bb));
    TS_ASSERT(! bb);
    Debug("boolattr") << "get flag 3 on c (should be F)\n";
    TS_ASSERT(c.getAttribute(TestFlag3(), bb));
    TS_ASSERT(! bb);
    Debug("boolattr") << "get flag 3 on unnamed (should be F)\n";
    TS_ASSERT(unnamed.getAttribute(TestFlag3(), bb));
    TS_ASSERT(! bb);

    Debug("boolattr") << "get flag 4 on a (should be F)\n";
    TS_ASSERT(a.getAttribute(TestFlag4(), bb));
    TS_ASSERT(! bb);
    Debug("boolattr") << "get flag 4 on b (should be F)\n";
    TS_ASSERT(b.getAttribute(TestFlag4(), bb));
    TS_ASSERT(! bb);
    Debug("boolattr") << "get flag 4 on c (should be F)\n";
    TS_ASSERT(c.getAttribute(TestFlag4(), bb));
    TS_ASSERT(! bb);
    Debug("boolattr") << "get flag 4 on unnamed (should be F)\n";
    TS_ASSERT(unnamed.getAttribute(TestFlag4(), bb));
    TS_ASSERT(! bb);

    Debug("boolattr") << "get flag 5 on a (should be F)\n";
    TS_ASSERT(a.getAttribute(TestFlag5(), bb));
    TS_ASSERT(! bb);
    Debug("boolattr") << "get flag 5 on b (should be F)\n";
    TS_ASSERT(b.getAttribute(TestFlag5(), bb));
    TS_ASSERT(! bb);
    Debug("boolattr") << "get flag 5 on c (should be F)\n";
    TS_ASSERT(c.getAttribute(TestFlag5(), bb));
    TS_ASSERT(! bb);
    Debug("boolattr") << "get flag 5 on unnamed (should be F)\n";
    TS_ASSERT(unnamed.getAttribute(TestFlag5(), bb));
    TS_ASSERT(! bb);

    // setting boolean flags
    Debug("boolattr") << "set flag 1 on a to T\n";
    a.setAttribute(TestFlag1(), true);
    Debug("boolattr") << "set flag 1 on b to F\n";
    b.setAttribute(TestFlag1(), false);
    Debug("boolattr") << "set flag 1 on c to F\n";
    c.setAttribute(TestFlag1(), false);
    Debug("boolattr") << "set flag 1 on unnamed to T\n";
    unnamed.setAttribute(TestFlag1(), true);

    Debug("boolattr") << "set flag 2 on a to F\n";
    a.setAttribute(TestFlag2(), false);
    Debug("boolattr") << "set flag 2 on b to T\n";
    b.setAttribute(TestFlag2(), true);
    Debug("boolattr") << "set flag 2 on c to T\n";
    c.setAttribute(TestFlag2(), true);
    Debug("boolattr") << "set flag 2 on unnamed to F\n";
    unnamed.setAttribute(TestFlag2(), false);

    Debug("boolattr") << "set flag 3 on a to T\n";
    a.setAttribute(TestFlag3(), true);
    Debug("boolattr") << "set flag 3 on b to T\n";
    b.setAttribute(TestFlag3(), true);
    Debug("boolattr") << "set flag 3 on c to T\n";
    c.setAttribute(TestFlag3(), true);
    Debug("boolattr") << "set flag 3 on unnamed to T\n";
    unnamed.setAttribute(TestFlag3(), true);

    Debug("boolattr") << "set flag 4 on a to T\n";
    a.setAttribute(TestFlag4(), true);
    Debug("boolattr") << "set flag 4 on b to T\n";
    b.setAttribute(TestFlag4(), true);
    Debug("boolattr") << "set flag 4 on c to T\n";
    c.setAttribute(TestFlag4(), true);
    Debug("boolattr") << "set flag 4 on unnamed to T\n";
    unnamed.setAttribute(TestFlag4(), true);

    Debug("boolattr") << "set flag 5 on a to T\n";
    a.setAttribute(TestFlag5(), true);
    Debug("boolattr") << "set flag 5 on b to T\n";
    b.setAttribute(TestFlag5(), true);
    Debug("boolattr") << "set flag 5 on c to F\n";
    c.setAttribute(TestFlag5(), false);
    Debug("boolattr") << "set flag 5 on unnamed to T\n";
    unnamed.setAttribute(TestFlag5(), true);

    TS_ASSERT(a.getAttribute(VarNameAttr()) == "a");
    TS_ASSERT(a.getAttribute(VarNameAttr()) != "b");
    TS_ASSERT(a.getAttribute(VarNameAttr()) != "c");
    TS_ASSERT(a.getAttribute(VarNameAttr()) != "");

    TS_ASSERT(b.getAttribute(VarNameAttr()) != "a");
    TS_ASSERT(b.getAttribute(VarNameAttr()) == "b");
    TS_ASSERT(b.getAttribute(VarNameAttr()) != "c");
    TS_ASSERT(b.getAttribute(VarNameAttr()) != "");

    TS_ASSERT(c.getAttribute(VarNameAttr()) != "a");
    TS_ASSERT(c.getAttribute(VarNameAttr()) != "b");
    TS_ASSERT(c.getAttribute(VarNameAttr()) == "c");
    TS_ASSERT(c.getAttribute(VarNameAttr()) != "");

    TS_ASSERT(unnamed.getAttribute(VarNameAttr()) != "a");
    TS_ASSERT(unnamed.getAttribute(VarNameAttr()) != "b");
    TS_ASSERT(unnamed.getAttribute(VarNameAttr()) != "c");
    TS_ASSERT(unnamed.getAttribute(VarNameAttr()) == "");

    TS_ASSERT(! unnamed.hasAttribute(VarNameAttr()));

    TS_ASSERT(! a.hasAttribute(TestStringAttr1()));
    TS_ASSERT(! b.hasAttribute(TestStringAttr1()));
    TS_ASSERT(! c.hasAttribute(TestStringAttr1()));
    TS_ASSERT(! unnamed.hasAttribute(TestStringAttr1()));

    TS_ASSERT(! a.hasAttribute(TestStringAttr2()));
    TS_ASSERT(! b.hasAttribute(TestStringAttr2()));
    TS_ASSERT(! c.hasAttribute(TestStringAttr2()));
    TS_ASSERT(! unnamed.hasAttribute(TestStringAttr2()));

    Debug("boolattr") << "get flag 1 on a (should be T)\n";
    TS_ASSERT(a.getAttribute(TestFlag1()));
    Debug("boolattr") << "get flag 1 on b (should be F)\n";
    TS_ASSERT(! b.getAttribute(TestFlag1()));
    Debug("boolattr") << "get flag 1 on c (should be F)\n";
    TS_ASSERT(! c.getAttribute(TestFlag1()));
    Debug("boolattr") << "get flag 1 on unnamed (should be T)\n";
    TS_ASSERT(unnamed.getAttribute(TestFlag1()));

    Debug("boolattr") << "get flag 2 on a (should be F)\n";
    TS_ASSERT(! a.getAttribute(TestFlag2()));
    Debug("boolattr") << "get flag 2 on b (should be T)\n";
    TS_ASSERT(b.getAttribute(TestFlag2()));
    Debug("boolattr") << "get flag 2 on c (should be T)\n";
    TS_ASSERT(c.getAttribute(TestFlag2()));
    Debug("boolattr") << "get flag 2 on unnamed (should be F)\n";
    TS_ASSERT(! unnamed.getAttribute(TestFlag2()));

    Debug("boolattr") << "get flag 3 on a (should be T)\n";
    TS_ASSERT(a.getAttribute(TestFlag3()));
    Debug("boolattr") << "get flag 3 on b (should be T)\n";
    TS_ASSERT(b.getAttribute(TestFlag3()));
    Debug("boolattr") << "get flag 3 on c (should be T)\n";
    TS_ASSERT(c.getAttribute(TestFlag3()));
    Debug("boolattr") << "get flag 3 on unnamed (should be T)\n";
    TS_ASSERT(unnamed.getAttribute(TestFlag3()));

    Debug("boolattr") << "get flag 4 on a (should be T)\n";
    TS_ASSERT(a.getAttribute(TestFlag4()));
    Debug("boolattr") << "get flag 4 on b (should be T)\n";
    TS_ASSERT(b.getAttribute(TestFlag4()));
    Debug("boolattr") << "get flag 4 on c (should be T)\n";
    TS_ASSERT(c.getAttribute(TestFlag4()));
    Debug("boolattr") << "get flag 4 on unnamed (should be T)\n";
    TS_ASSERT(unnamed.getAttribute(TestFlag4()));

    Debug("boolattr") << "get flag 5 on a (should be T)\n";
    TS_ASSERT(a.getAttribute(TestFlag5()));
    Debug("boolattr") << "get flag 5 on b (should be T)\n";
    TS_ASSERT(b.getAttribute(TestFlag5()));
    Debug("boolattr") << "get flag 5 on c (should be F)\n";
    TS_ASSERT(! c.getAttribute(TestFlag5()));
    Debug("boolattr") << "get flag 5 on unnamed (should be T)\n";
    TS_ASSERT(unnamed.getAttribute(TestFlag5()));

    a.setAttribute(TestStringAttr1(), "foo");
    b.setAttribute(TestStringAttr1(), "bar");
    c.setAttribute(TestStringAttr1(), "baz");

    TS_ASSERT(a.getAttribute(VarNameAttr()) == "a");
    TS_ASSERT(a.getAttribute(VarNameAttr()) != "b");
    TS_ASSERT(a.getAttribute(VarNameAttr()) != "c");
    TS_ASSERT(a.getAttribute(VarNameAttr()) != "");

    TS_ASSERT(b.getAttribute(VarNameAttr()) != "a");
    TS_ASSERT(b.getAttribute(VarNameAttr()) == "b");
    TS_ASSERT(b.getAttribute(VarNameAttr()) != "c");
    TS_ASSERT(b.getAttribute(VarNameAttr()) != "");

    TS_ASSERT(c.getAttribute(VarNameAttr()) != "a");
    TS_ASSERT(c.getAttribute(VarNameAttr()) != "b");
    TS_ASSERT(c.getAttribute(VarNameAttr()) == "c");
    TS_ASSERT(c.getAttribute(VarNameAttr()) != "");

    TS_ASSERT(unnamed.getAttribute(VarNameAttr()) != "a");
    TS_ASSERT(unnamed.getAttribute(VarNameAttr()) != "b");
    TS_ASSERT(unnamed.getAttribute(VarNameAttr()) != "c");
    TS_ASSERT(unnamed.getAttribute(VarNameAttr()) == "");

    TS_ASSERT(! unnamed.hasAttribute(VarNameAttr()));

    TS_ASSERT(a.hasAttribute(TestStringAttr1()));
    TS_ASSERT(b.hasAttribute(TestStringAttr1()));
    TS_ASSERT(c.hasAttribute(TestStringAttr1()));
    TS_ASSERT(! unnamed.hasAttribute(TestStringAttr1()));

    TS_ASSERT(! a.hasAttribute(TestStringAttr2()));
    TS_ASSERT(! b.hasAttribute(TestStringAttr2()));
    TS_ASSERT(! c.hasAttribute(TestStringAttr2()));
    TS_ASSERT(! unnamed.hasAttribute(TestStringAttr2()));

    a.setAttribute(VarNameAttr(), "b");
    b.setAttribute(VarNameAttr(), "c");
    c.setAttribute(VarNameAttr(), "a");

    TS_ASSERT(c.getAttribute(VarNameAttr()) == "a");
    TS_ASSERT(c.getAttribute(VarNameAttr()) != "b");
    TS_ASSERT(c.getAttribute(VarNameAttr()) != "c");
    TS_ASSERT(c.getAttribute(VarNameAttr()) != "");

    TS_ASSERT(a.getAttribute(VarNameAttr()) != "a");
    TS_ASSERT(a.getAttribute(VarNameAttr()) == "b");
    TS_ASSERT(a.getAttribute(VarNameAttr()) != "c");
    TS_ASSERT(a.getAttribute(VarNameAttr()) != "");

    TS_ASSERT(b.getAttribute(VarNameAttr()) != "a");
    TS_ASSERT(b.getAttribute(VarNameAttr()) != "b");
    TS_ASSERT(b.getAttribute(VarNameAttr()) == "c");
    TS_ASSERT(b.getAttribute(VarNameAttr()) != "");

    TS_ASSERT(unnamed.getAttribute(VarNameAttr()) != "a");
    TS_ASSERT(unnamed.getAttribute(VarNameAttr()) != "b");
    TS_ASSERT(unnamed.getAttribute(VarNameAttr()) != "c");
    TS_ASSERT(unnamed.getAttribute(VarNameAttr()) == "");

    TS_ASSERT(! unnamed.hasAttribute(VarNameAttr()));
  }
};
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback