37 using lumiera::error::LUMIERA_ERROR_LOGIC;
41 typedef ScopedHolder<Dummy> HolderD;
42 typedef ScopedPtrHolder<Dummy> PtrHolderD;
60 cout <<
"checking ScopedHolder<Dummy>...\n";
61 checkAllocation<HolderD>();
62 checkErrorHandling<HolderD>();
63 checkCopyProtocol<HolderD>();
64 checkSTLContainer<HolderD>();
66 cout <<
"checking ScopedPtrHolder<Dummy>...\n";
67 checkAllocation<PtrHolderD>();
68 checkErrorHandling<PtrHolderD>();
69 checkCopyProtocol<PtrHolderD>();
70 checkSTLContainer<PtrHolderD>();
73 void create_contained_object (HolderD& holder) { holder.create(); }
74 void create_contained_object (PtrHolderD& holder) { holder.reset(
new Dummy()); }
81 CHECK (0 == Dummy::checksum());
85 CHECK (0 == Dummy::checksum());
87 create_contained_object (holder);
89 CHECK (
false !=
bool(holder));
90 CHECK (
bool(holder) !=
false);
92 CHECK (0 < Dummy::checksum());
94 CHECK (holder->calc(2) == 2 + Dummy::checksum());
96 Dummy *rawP = holder.get();
99 CHECK (rawP == &(*holder));
100 CHECK (rawP->calc(-5) == holder->calc(-5));
102 TRACE (
test,
"holder at %p", &holder);
103 TRACE (
test,
"object at %p", holder.get() );
104 TRACE (
test,
"size(object) = %zu",
sizeof(*holder));
105 TRACE (
test,
"size(holder) = %zu",
sizeof(holder));
107 CHECK (0 == Dummy::checksum());
115 CHECK (0 == Dummy::checksum());
119 Dummy::activateCtorFailure();
122 create_contained_object (holder);
123 NOTREACHED (
"expect failure in ctor");
127 CHECK (0 != Dummy::checksum());
128 Dummy::checksum() -= val;
129 CHECK (0 == Dummy::checksum());
133 Dummy::activateCtorFailure(
false);
135 CHECK (0 == Dummy::checksum());
143 CHECK (0 == Dummy::checksum());
152 create_contained_object (holder);
154 long currSum = Dummy::checksum();
155 void* adr = holder.get();
160 CHECK (holder.get()==adr);
161 CHECK (Dummy::checksum()==currSum);
166 CHECK (holder.get()==adr);
167 CHECK (Dummy::checksum()==currSum);
169 create_contained_object (holder2);
171 CHECK (Dummy::checksum() != currSum);
172 currSum = Dummy::checksum();
177 CHECK (holder.get()==adr);
178 CHECK (Dummy::checksum()==currSum);
183 CHECK (Dummy::checksum()==currSum);
185 CHECK (0 == Dummy::checksum());
196 typedef std::map<int,HO> MapHO;
198 CHECK (0 == Dummy::checksum());
201 CHECK (isnil (maph));
203 for (uint i=0; i<100; ++i)
205 HO & contained = maph[i];
209 CHECK (0 == Dummy::checksum());
210 CHECK (!isnil (maph));
211 CHECK (100==maph.size());
213 for (uint i=0; i<100; ++i)
215 create_contained_object (maph[i]);
217 CHECK (0 < maph[i]->calc(12));
219 CHECK (100==maph.size());
220 CHECK (0 != Dummy::checksum());
223 long value55 = maph[55]->calc(0);
224 long currSum = Dummy::checksum();
226 CHECK (1 == maph.erase(55));
227 CHECK (Dummy::checksum() == currSum - value55);
228 CHECK (maph.size() == 99);
233 CHECK (maph.size() == 100);
235 CHECK (0 == Dummy::checksum());
Some wrappers for coping with ownership problems.
#define VERIFY_ERROR(ERROR_ID, ERRONEOUS_STATEMENT)
Macro to verify that a statement indeed raises an exception.
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...
unittest helper code: test dummy objects to track instances.
A collection of frequently used helper functions to support unit testing.
A Dummy object for tests.
Lumiera error handling (C++ interface).