File: testDict.cpp

package info (click to toggle)
rdkit 201809.1%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 123,688 kB
  • sloc: cpp: 230,509; python: 70,501; java: 6,329; ansic: 5,427; sql: 1,899; yacc: 1,739; lex: 1,243; makefile: 445; xml: 229; fortran: 183; sh: 123; cs: 93
file content (731 lines) | stat: -rw-r--r-- 19,099 bytes parent folder | download
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
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
//
// Copyright 2001-2008 Randal M. Henne, Greg Landrum and
//                     Rational Discovery LLC
//
//  @@ All Rights Reserved @@
//  This file is part of the RDKit.
//  The contents are covered by the terms of the BSD license
//  which is included in the file license.txt, found at the root
//  of the RDKit source tree.
//
//

#include <RDGeneral/test.h>
#include "types.h"
#include <RDGeneral/Invariant.h>
#include <RDGeneral/RDAny.h>
#include <RDGeneral/Dict.h>
#include <RDGeneral/RDLog.h>
#include <RDGeneral/utils.h>
#include <boost/shared_ptr.hpp>
#include <vector>
#include <ctime>

using namespace RDKit;
using namespace std;

struct Foo {
  int bar;
  float baz;
  ~Foo() { std::cerr << "deleted!" << std::endl; }
};

void testGithub940() {
  BOOST_LOG(rdErrorLog)
      << "Testing Github940: property dictionaries leaking memory" << std::endl;

  // a couple small tests to check for memory leaks. Only useful with valgrind
  {  // tests computed props
    STR_VECT computed;
    auto *d = new Dict();
    d->setVal(RDKit::detail::computedPropName, computed);
    computed.push_back("foo");
    d->setVal(RDKit::detail::computedPropName, computed);
    delete d;
  }
  {  // tests computed props
    STR_VECT computed;
    auto *d = new Dict();
    d->setVal(RDKit::detail::computedPropName, computed);
    computed.push_back("foo");
    d->setVal(RDKit::detail::computedPropName, computed);
    d->clearVal(RDKit::detail::computedPropName);
    delete d;
  }
  BOOST_LOG(rdErrorLog) << "\tdone" << std::endl;
}

void testRDAny() {
  std::cerr << "Testing RDValue" << std::endl;
  { RDAny v(-2147450880); }

  {
    int vi = 0;
    RDValue v(0);
    for (int i = 0; i < 100; ++i) {
      vi += i;
      v = rdvalue_cast<int>(v) + i;
      TEST_ASSERT(vi == rdvalue_cast<int>(v));
    }
  }
  std::cerr << "Testing RDAny" << std::endl;
  {
    RDAny a(1);
    RDAny b = a;
    TEST_ASSERT(rdany_cast<int>(a) == 1);
    TEST_ASSERT(rdany_cast<int>(b) == 1);
  }

  {
    RDAny a(1);
    RDAny b = a;
    TEST_ASSERT(rdany_cast<int>(a) == 1);
    TEST_ASSERT(rdany_cast<int>(b) == rdany_cast<int>(a));
    std::map<std::string, RDAny> foo;
    foo["foo"] = a;
    foo["bar"] = std::string("This is a test");
    TEST_ASSERT(rdany_cast<int>(foo["foo"]) == 1);
    TEST_ASSERT(rdany_cast<int>(foo["foo"]) == rdany_cast<int>(a));
    TEST_ASSERT(rdany_cast<std::string>(foo["bar"]) == "This is a test");
  }

  {
    bool a = true;
    RDValue v(a);
    TEST_ASSERT(rdvalue_cast<bool>(v) == true);
    v = (int)10;
    TEST_ASSERT(rdvalue_cast<int>(v) == 10);
  }

  {
    Dict d;
    bool a = true;
    d.setVal("foo", a);
    d.getVal<bool>("foo");
  }

  {  // tests computed props
    STR_VECT computed;
    Dict d;
    d.setVal(RDKit::detail::computedPropName, computed);
    computed.push_back("foo");
    d.setVal(RDKit::detail::computedPropName, computed);
    STR_VECT computed2 = d.getVal<STR_VECT>(RDKit::detail::computedPropName);
    TEST_ASSERT(computed2[0] == "foo");
    Dict d2(d);
    computed2 = d2.getVal<STR_VECT>(RDKit::detail::computedPropName);
    TEST_ASSERT(computed2[0] == "foo");
  }

  {
    Dict d;
    // int v=1;
    // d.setVal("foo", v);
    // TEST_ASSERT(d.getVal<int>("foo") == 1, "bad getval");

    std::vector<int> fooV;
    fooV.resize(3);
    fooV[0] = 1;
    fooV[1] = 2;
    fooV[2] = 3;
    if (0) {
      std::vector<int> fooV2;
      std::cerr << "send int vect" << std::endl;
      RDAny a(fooV);
      std::cerr << "retrieve int vect" << std::endl;
      fooV2 = rdany_cast<std::vector<int>>(a);
      TEST_ASSERT(fooV == fooV2);
    }

    {
      std::vector<int> fooV2;
      std::cerr << "dict set int vect" << std::endl;
      d.setVal("bar", fooV);
      std::cerr << "dict get int vect" << std::endl;
      d.getVal("bar", fooV2);
      TEST_ASSERT(fooV == fooV2);
    }
  }

  {
    std::vector<int> v;
    for (int i = 0; i < 4; ++i) v.push_back(i);

    RDAny foo(v);
    RDAny bar = foo;
    RDAny baz(foo);

    for (int i = 0; i < 4; ++i) {
      TEST_ASSERT(rdany_cast<std::vector<int>>(foo)[i] == i);
      TEST_ASSERT(rdany_cast<std::vector<int>>(bar)[i] == i);
      TEST_ASSERT(rdany_cast<std::vector<int>>(baz)[i] == i);
    }
  }

  {
    std::vector<double> v;
    for (double i = 0; i < 4; ++i) v.push_back(i);

    RDAny foo(v);

    for (int i = 0; i < 4; ++i) {
      TEST_ASSERT(rdany_cast<std::vector<double>>(foo)[i] == i);
    }

    RDAny b = foo;

    for (int i = 0; i < 4; ++i) {
      TEST_ASSERT(rdany_cast<std::vector<double>>(b)[i] == i);
    }
  }
  const int loops = 10000000;
  {
    std::clock_t clock1 = std::clock();
    boost::any v;
    for (int i = 0; i < loops; ++i) {
      v = i;
    }
    std::clock_t clock2 = std::clock();

    std::cout << "static boost any:"
              << (double)(clock2 - clock1) / CLOCKS_PER_SEC << " s"
              << std::endl;
  }
  {
    std::clock_t clock1 = std::clock();
    boost::any *v = nullptr, *vv;
    for (int i = 0; i < loops; ++i) {
      vv = new boost::any(v ? boost::any_cast<int>(*v) + i : i);
      delete v;
      v = vv;
    }
    delete vv;
    std::clock_t clock2 = std::clock();

    std::cout << "dynamic boost any:"
              << (double)(clock2 - clock1) / CLOCKS_PER_SEC << " s"
              << std::endl;
  }

  {
    std::clock_t clock1 = std::clock();
    RDAny v;
    for (int i = 0; i < loops; ++i) {
      v = i;
    }
    std::clock_t clock2 = std::clock();

    std::cout << "static RDAny:" << (double)(clock2 - clock1) / CLOCKS_PER_SEC
              << " s" << std::endl;
  }

  {
    std::clock_t clock1 = std::clock();
    RDAny *v = nullptr, *vv;
    for (int i = 0; i < loops; ++i) {
      vv = new RDAny(v ? rdany_cast<int>(*v) + i : i);
      delete v;
      v = vv;
    }
    delete vv;
    std::clock_t clock2 = std::clock();

    std::cout << "dynamic RDAny:" << (double)(clock2 - clock1) / CLOCKS_PER_SEC
              << " s" << std::endl;
  }

  {
    std::clock_t clock1 = std::clock();
    RDValue v;
    for (int i = 0; i < loops; ++i) {
      v = i;
    }
    std::clock_t clock2 = std::clock();

    std::cout << "static RDValue:" << (double)(clock2 - clock1) / CLOCKS_PER_SEC
              << " s" << std::endl;
  }

  {
    std::clock_t clock1 = std::clock();
    RDValue v(0);
    for (int i = 0; i < loops; ++i) {
      v = RDValue(rdvalue_cast<int>(v) + i);
    }

    std::clock_t clock2 = std::clock();

    std::cout << "dynamic RDValue:"
              << (double)(clock2 - clock1) / CLOCKS_PER_SEC << " s"
              << std::endl;
  }

  {  // checks replacement with vector
    RDAny vv(2.0);
    TEST_ASSERT(rdany_cast<double>(vv) == 2.0);

    std::vector<int> vect;
    vect.push_back(1);
    vv = vect;
    TEST_ASSERT(rdany_cast<std::vector<int>>(vv)[0] == 1);

    // tests copy
    RDAny vvv(vv);

    TEST_ASSERT(rdany_cast<std::vector<int>>(vvv)[0] == 1);
  }

  {
    // Checks fallback to Any
    std::vector<std::pair<int, int>> pvect;
    pvect.push_back(std::make_pair<int, int>(2, 2));
    boost::any any1(pvect);
    boost::any_cast<std::vector<std::pair<int, int>>>(any1);
    boost::any_cast<std::vector<std::pair<int, int>> &>(any1);
    boost::any_cast<const std::vector<std::pair<int, int>> &>(any1);

    RDAny vv(pvect);
    boost::any &any = rdany_cast<boost::any &>(vv);
    boost::any_cast<std::vector<std::pair<int, int>>>(any);
    boost::any_cast<std::vector<std::pair<int, int>> &>(any);
    boost::any_cast<const std::vector<std::pair<int, int>> &>(any);

    const std::vector<std::pair<int, int>> &pv =
        rdany_cast<std::vector<std::pair<int, int>>>(vv);
    TEST_ASSERT(pv[0].first == 2);
    RDAny vvv(vv);
    TEST_ASSERT(
        (rdany_cast<std::vector<std::pair<int, int>>>(vvv)[0].first == 2));
  }

  {
    // Check pointers -- RDAny doesn't delete these, must do them manually
    auto *p = new std::vector<int>();
    p->push_back(100);
    RDAny v(p);
    RDAny vv(v);
    try {
      rdany_cast<std::vector<int>>(v);
#ifndef UNSAFE_RDVALUE
      PRECONDITION(0, "Should throw bad cast");
#endif
    } catch (boost::bad_any_cast &e) {
    }

    TEST_ASSERT((*rdany_cast<std::vector<int> *>(vv))[0] == 100);
    TEST_ASSERT((*rdany_cast<std::vector<int> *>((const RDAny &)vv))[0] == 100);
    delete p;

    auto *m = new std::map<int, int>();
    (*m)[0] = 1;
    RDAny mv(m);
    // leaks
    std::map<int, int> *anym = rdany_cast<std::map<int, int> *>(mv);
    TEST_ASSERT(anym->find(0) != anym->end());
    delete anym;
  }

  {
    // check shared ptrs -- boost::any deletes these :)
    typedef boost::shared_ptr<std::vector<int>> vptr;
    vptr p(new std::vector<int>());
    p->push_back(100);
    RDAny v(p);
    RDAny vv(v);
    TEST_ASSERT((*rdany_cast<vptr>(v))[0] == 100);
    TEST_ASSERT((*rdany_cast<vptr>(vv))[0] == 100);
    TEST_ASSERT((*rdany_cast<vptr>((const RDAny &)vv))[0] == 100);

    typedef boost::shared_ptr<std::map<int, int>> mptr;
    mptr m(new std::map<int, int>());
    (*m)[0] = 1;
    RDAny mv(m);
    // leaks
    mptr anym = rdany_cast<mptr>(mv);
    TEST_ASSERT(anym->find(0) != anym->end());

    RDAny any3(boost::shared_ptr<Foo>(new Foo));
    TEST_ASSERT(any3.m_value.getTag() == RDTypeTag::AnyTag);
  }
}

class DictCon {
 public:
  DictCon() { d.reset(); };
  DictCon(const DictCon &other) { d = other.d; };
  DictCon &operator=(const DictCon &other) {
    d = other.d;
    return *this;
  };
  Dict *getDict() { return &d; };

 private:
  Dict d;
};

void testStringVals() {
  BOOST_LOG(rdErrorLog) << "-------------------------------------" << std::endl;
  BOOST_LOG(rdErrorLog) << "Testing String Pickle Roundtrips." << std::endl;
  {
    Dict d;
    std::string sv;
    sv = "1";
    d.setVal("foo", sv);
    int iv;
    d.getVal("foo", iv);
    TEST_ASSERT(iv == 1);
  }
  {
    Dict d;
    d.setVal("foo", "1");
    int iv;
    d.getVal("foo", iv);
    TEST_ASSERT(iv == 1);
  }
  {
    Dict d;
    std::string sv;
    sv = "1.3";
    d.setVal("foo", sv);
    double dv;
    d.getVal("foo", dv);
    TEST_ASSERT(feq(dv, 1.3));
  }

  BOOST_LOG(rdErrorLog) << "\tdone" << std::endl;
}

void testVectToString() {
  BOOST_LOG(rdErrorLog) << "-------------------------------------" << std::endl;
  BOOST_LOG(rdErrorLog) << "Testing conversion of vect to string." << std::endl;
  {
    Dict d;
    std::vector<int> v;
    v.push_back(1);
    v.push_back(0);
    d.setVal("foo", v);
    std::string sv;
    d.getVal("foo", sv);
    TEST_ASSERT(sv == "[1,0,]");
  }
  {
    Dict d;
    std::vector<unsigned int> v;
    v.push_back(1);
    v.push_back(0);
    d.setVal("foo", v);
    std::string sv;
    d.getVal("foo", sv);
    TEST_ASSERT(sv == "[1,0,]");
  }
  {
    Dict d;
    std::vector<double> v;
    v.push_back(1.2);
    v.push_back(0);
    d.setVal("foo", v);
    std::string sv;
    d.getVal("foo", sv);
    std::cerr << sv << std::endl;
    TEST_ASSERT(sv == "[1.2,0,]");
  }
  {
    Dict d;
    std::vector<float> v;
    v.push_back(10001.f);
    v.push_back(0);
    d.setVal("foo", v);
    std::string sv;
    d.getVal("foo", sv);
    std::cerr << sv << std::endl;
    TEST_ASSERT(sv == "[10001,0,]");
  }

  BOOST_LOG(rdErrorLog) << "\tdone" << std::endl;
}

void testConstReturns() {
  BOOST_LOG(rdErrorLog) << "-------------------------------------" << std::endl;
  BOOST_LOG(rdErrorLog) << "Testing returning const references." << std::endl;
  {
    std::string v = "foo";
    RDAny anyv(v);

    std::string tgt = rdany_cast<std::string>(anyv);
    const std::string &ctgt = rdany_cast<std::string>(anyv);
    TEST_ASSERT(ctgt != "");
  }

  {
    Dict d;
    std::string v = "foo";
    d.setVal("foo", v);

    // const std::string nv=d.getVal<const std::string &>("foo");
    std::string nv = d.getVal<std::string>("foo");
    TEST_ASSERT(nv == "foo");
  }

#if 0
  {
    Dict d;
    std::string v="foo";
    d.setVal("foo",v);

    double ls=0;
    BOOST_LOG(rdErrorLog) << "copy" << std::endl;
    for(int i=0;i<100000000;++i){
      std::string nv=d.getVal<std::string>("foo");
      ls+= nv.size();
    }
    BOOST_LOG(rdErrorLog) << "done: "<<ls << std::endl;
    ls=0;
    BOOST_LOG(rdErrorLog) << "ref" << std::endl;
    for(int i=0;i<100000000;++i){
      const std::string &nv=d.getVal<std::string>("foo");
      ls+= nv.size();
    }
    BOOST_LOG(rdErrorLog) << "done: "<<ls << std::endl;
    //std::string nv=d.getVal<std::string>("foo");
  }
#else
  {
    // int nreps=100000000;
    int nreps = 100000;
    Dict d;
    std::string v = "foo";
    RDAny anyv(v);
    d.setVal("foo", v);

    std::clock_t start, end;

    double ls = 0;
    BOOST_LOG(rdErrorLog) << "any cast" << std::endl;
    start = std::clock();
    for (int i = 0; i < nreps; ++i) {
      const std::string &nv = rdany_cast<std::string>(anyv);
      ls += nv.size();
    }
    end = std::clock();
    BOOST_LOG(rdErrorLog) << "done: "
                          << (end - start) / (double)(CLOCKS_PER_SEC) << " "
                          << ls << std::endl;

    ls = 0;
    BOOST_LOG(rdErrorLog) << "copy" << std::endl;
    start = std::clock();
    for (int i = 0; i < nreps; ++i) {
      std::string nv = rdany_cast<std::string>(anyv);
      ls += nv.size();
    }
    end = std::clock();
    BOOST_LOG(rdErrorLog) << "done: "
                          << (end - start) / (double)(CLOCKS_PER_SEC) << " "
                          << ls << std::endl;

    ls = 0;
    BOOST_LOG(rdErrorLog) << "ref" << std::endl;
    start = std::clock();
    for (int i = 0; i < nreps; ++i) {
      const std::string &nv = rdany_cast<std::string>(anyv);
      ls += nv.size();
    }
    end = std::clock();
    BOOST_LOG(rdErrorLog) << "done: "
                          << (end - start) / (double)(CLOCKS_PER_SEC) << " "
                          << ls << std::endl;

    ls = 0;
    BOOST_LOG(rdErrorLog) << "dict" << std::endl;
    start = std::clock();
    for (int i = 0; i < nreps; ++i) {
      const std::string &nv = d.getVal<std::string>("foo");
      ls += nv.size();
    }
    end = std::clock();
    BOOST_LOG(rdErrorLog) << "done: "
                          << (end - start) / (double)(CLOCKS_PER_SEC) << " "
                          << ls << std::endl;

    ls = 0;
    BOOST_LOG(rdErrorLog) << "ref with hasVal" << std::endl;
    start = std::clock();
    std::string k = "foo";
    for (int i = 0; i < nreps; ++i) {
      if (d.hasVal(k)) {
        const std::string &nv = rdany_cast<std::string>(anyv);
        ls += nv.size();
      }
    }
    end = std::clock();
    BOOST_LOG(rdErrorLog) << "done: "
                          << (end - start) / (double)(CLOCKS_PER_SEC) << " "
                          << ls << std::endl;

    // std::string nv=d.getVal<std::string>("foo");
  }

#endif

  BOOST_LOG(rdErrorLog) << "\tdone" << std::endl;
}

void testUpdate() {
  BOOST_LOG(rdErrorLog) << "-------------------------------------" << std::endl;
  BOOST_LOG(rdErrorLog) << "Testing dict update." << std::endl;

  {
    Dict d;
    std::string sv;
    sv = "1.3";
    d.setVal("foo", sv);
    double dv = 3.0;
    d.setVal("foo2", dv);
    std::vector<int> f;
    f.push_back(1);
    f.push_back(2);
    d.setVal("foo3", f);

    Dict d2;
    d2.update(d);
    TEST_ASSERT(d.getVal<std::string>("foo") == d2.getVal<std::string>("foo"));
    TEST_ASSERT(d.getVal<double>("foo2") == d2.getVal<double>("foo2"));
    TEST_ASSERT(d.getVal<std::vector<int>>("foo3") ==
                d2.getVal<std::vector<int>>("foo3"));
  }

  {  // a few tests to make sure copying/updating with nonPOD data is ok
    Dict d;
    std::string sv;
    sv = "1.3";
    d.setVal("foo", sv);
    double dv = 3.0;
    d.setVal("foo2", dv);
    std::vector<int> f;
    f.push_back(1);
    f.push_back(2);
    d.setVal("foo3", f);
    {
      Dict d2;
      d2.setVal("foo", 1);
      d2.update(d, true);
      TEST_ASSERT(d2.getVal<std::string>("foo") == "1.3");
      TEST_ASSERT(d.getVal<double>("foo2") == d2.getVal<double>("foo2"));
      TEST_ASSERT(d.getVal<std::vector<int>>("foo3") ==
                  d2.getVal<std::vector<int>>("foo3"));
    }

    {
      Dict d2 = d;
      d2.setVal("foo", 1);
      TEST_ASSERT(1 == d2.getVal<int>("foo"));
      TEST_ASSERT(d.getVal<double>("foo2") == d2.getVal<double>("foo2"));
      TEST_ASSERT(d.getVal<std::vector<int>>("foo3") ==
                  d2.getVal<std::vector<int>>("foo3"));
    }

    {
      Dict d2(d);
      TEST_ASSERT(d.getVal<double>("foo2") == d2.getVal<double>("foo2"));
      TEST_ASSERT(d.getVal<std::vector<int>>("foo3") ==
                  d2.getVal<std::vector<int>>("foo3"));
    }
  }
  BOOST_LOG(rdErrorLog) << "\tdone" << std::endl;
}

int main() {
  RDLog::InitLogs();
  testGithub940();

#if 1
  testRDAny();
  Dict d;
  INT_VECT fooV;
  fooV.resize(3);
  BOOST_LOG(rdInfoLog) << "dict test" << std::endl;
  TEST_ASSERT(!d.hasVal("foo"));
  int x = 1;
  d.setVal("foo", x);
  TEST_ASSERT(d.hasVal("foo"));
  TEST_ASSERT(!d.hasVal("bar"));
  int v, v2;
  d.getVal("foo", v);
  TEST_ASSERT(v == 1);
  v2 = d.getVal<int>("foo");
  TEST_ASSERT(v2 == v);
  d.setVal("bar", fooV);
  d.getVal("foo", v);
  TEST_ASSERT(v == 1);
  v2 = d.getVal<int>("foo");
  TEST_ASSERT(v2 == v);
  INT_VECT fooV2, fooV3;
  d.getVal("bar", fooV2);
  fooV3 = d.getVal<INT_VECT>("bar");
  TEST_ASSERT(fooV == fooV2);
  TEST_ASSERT(fooV2 == fooV3);

  VECT_INT_VECT fooV4;
  fooV4.resize(3);
  TEST_ASSERT(!d.hasVal("baz"));
  d.setVal("baz", fooV4);
  TEST_ASSERT(d.hasVal("baz"));

  DictCon dc1;
  TEST_ASSERT(!dc1.getDict()->hasVal("foo"));
  int y = 1;
  dc1.getDict()->setVal("foo", y);
  TEST_ASSERT(dc1.getDict()->hasVal("foo"));
  TEST_ASSERT(!dc1.getDict()->hasVal("bar"));
  dc1.getDict()->setVal("bar", fooV);
  dc1.getDict()->getVal("foo", v);
  TEST_ASSERT(v == 1);
  dc1.getDict()->getVal("bar", fooV2);
  TEST_ASSERT(fooV == fooV2);
  fooV4.resize(3);
  TEST_ASSERT(!dc1.getDict()->hasVal("baz"));
  dc1.getDict()->setVal("baz", fooV4);
  TEST_ASSERT(dc1.getDict()->hasVal("baz"));

  dc1.getDict()->reset();

  DictCon dc2 = dc1;
  TEST_ASSERT(!dc2.getDict()->hasVal("foo"));
  int z = 1;
  dc2.getDict()->setVal("foo", z);
  TEST_ASSERT(dc2.getDict()->hasVal("foo"));
  TEST_ASSERT(!dc2.getDict()->hasVal("bar"));
  dc2.getDict()->setVal("bar", fooV);
  dc2.getDict()->getVal("foo", v);
  TEST_ASSERT(v == 1);
  dc2.getDict()->getVal("bar", fooV2);
  TEST_ASSERT(fooV == fooV2);
  fooV4.resize(3);
  TEST_ASSERT(!dc2.getDict()->hasVal("baz"));
  dc2.getDict()->setVal("baz", fooV4);
  TEST_ASSERT(dc2.getDict()->hasVal("baz"));

  DictCon dc3(dc2);
  TEST_ASSERT(dc3.getDict()->hasVal("foo"));
  dc3.getDict()->getVal("foo", v);
  TEST_ASSERT(v == 1);
  dc3.getDict()->getVal("bar", fooV2);
  TEST_ASSERT(fooV == fooV2);
  fooV4.resize(3);
  TEST_ASSERT(dc3.getDict()->hasVal("baz"));

  TEST_ASSERT(dc3.getDict()->hasVal("foo"));
  dc3.getDict()->getVal("foo", v);
  TEST_ASSERT(v == 1);
  dc3.getDict()->getVal("bar", fooV2);
  TEST_ASSERT(fooV == fooV2);
  fooV4.resize(3);
  TEST_ASSERT(dc3.getDict()->hasVal("baz"));

  testStringVals();
  testVectToString();
#endif
  testConstReturns();
  testUpdate();
  return 0;
}