Lumiera  0.pre.03
»edit your freedom«
null-value-test.cpp
Go to the documentation of this file.
1 /*
2  NullValue(Test) - verify the singleton holder for NIL or default values
3 
4  Copyright (C)
5  2010, Hermann Vosseler <Ichthyostega@web.de>
6 
7   **Lumiera** is free software; you can redistribute it and/or modify it
8   under the terms of the GNU General Public License as published by the
9   Free Software Foundation; either version 2 of the License, or (at your
10   option) any later version. See the file COPYING for further details.
11 
12 * *****************************************************************/
13 
21 #include "lib/test/run.hpp"
22 #include "lib/null-value.hpp"
23 #include "lib/util.hpp"
24 
25 
26 namespace lib {
27 namespace test{
28 
29  using util::isSameObject;
30 
31  namespace { // test data and helpers...
32 
33 
35  struct DummyType
36  {
37  static bool created;
38 
39  uint id_;
40 
41  DummyType()
42  : id_(1 + rani(100))
43  {
44  created = true;
45  }
46  };
47 
48  bool DummyType::created = false;
49 
50 
51  }
52 
53 
54 
55  /***********************************************************************************/
62  class NullValue_test : public Test
63  {
64 
65  void
66  run (Arg)
67  {
68  seedRand();
69  CHECK (long() == NullValue<long>::get());
70  CHECK (short() == NullValue<short>::get());
71  CHECK (isSameObject(NullValue<short>::get(), NullValue<short>::get()));
72 
73  CHECK (!DummyType::created);
74  DummyType copy (NullValue<DummyType>::get());
75  CHECK ( DummyType::created);
76 
77  CHECK ( copy.id_ == NullValue<DummyType>::get().id_);
78  CHECK (!isSameObject(NullValue<DummyType>::get(), copy));
79  CHECK ( isSameObject(NullValue<DummyType>::get(), NullValue<DummyType>::get()));
80  }
81  };
82 
83 
85  LAUNCHER (NullValue_test, "unit common");
86 
87 
88 }} // namespace lib::test
Definition: run.hpp:40
int rani(uint bound=_iBOUND())
Definition: random.hpp:135
Singleton holder for NIL or default value objects.
Definition: null-value.hpp:62
Singleton-style holder for NIL or default values.
Implementation namespace for support and library code.
Simplistic test class runner.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
bool isSameObject(A const &a, B const &b)
compare plain object identity, based directly on the referee&#39;s memory identities. ...
Definition: util.hpp:421