Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
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
26namespace lib {
27namespace test{
28
30
31 namespace { // test data and helpers...
32
33
35 struct DummyType
36 {
37 static bool created;
38
40
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 virtual 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
unsigned int uint
Definition integral.hpp:29
Implementation namespace for support and library code.
int rani(uint bound=_iBOUND())
Definition random.hpp:135
Test runner and basic definitions for tests.
bool isSameObject(A const &a, B const &b)
compare plain object identity, based directly on the referee's memory identities.
Definition util.hpp:421
Singleton-style holder for NIL or default values.
Simplistic test class runner.
#define LAUNCHER(_TEST_CLASS_, _GROUPS_)
Definition run.hpp:116
Singleton holder for NIL or default value objects.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...