46 using lumiera::error::LUMIERA_ERROR_LOGIC;
50 typedef ScopedHolder<Dummy> HolderD;
51 typedef ScopedPtrHolder<Dummy> PtrHolderD;
69 cout <<
"checking ScopedHolder<Dummy>...\n";
70 checkAllocation<HolderD>();
71 checkErrorHandling<HolderD>();
72 checkCopyProtocol<HolderD>();
73 checkSTLContainer<HolderD>();
75 cout <<
"checking ScopedPtrHolder<Dummy>...\n";
76 checkAllocation<PtrHolderD>();
77 checkErrorHandling<PtrHolderD>();
78 checkCopyProtocol<PtrHolderD>();
79 checkSTLContainer<PtrHolderD>();
82 void create_contained_object (HolderD& holder) { holder.create(); }
83 void create_contained_object (PtrHolderD& holder) { holder.reset(
new Dummy()); }
90 CHECK (0 == Dummy::checksum());
94 CHECK (0 == Dummy::checksum());
96 create_contained_object (holder);
98 CHECK (
false !=
bool(holder));
99 CHECK (
bool(holder) !=
false);
101 CHECK (0 < Dummy::checksum());
103 CHECK (holder->acc(2) == 2 + Dummy::checksum());
105 Dummy *rawP = holder.get();
108 CHECK (rawP == &(*holder));
109 CHECK (rawP->acc(-5) == holder->acc(-5));
111 TRACE (
test,
"holder at %p", &holder);
112 TRACE (
test,
"object at %p", holder.get() );
113 TRACE (
test,
"size(object) = %zu",
sizeof(*holder));
114 TRACE (
test,
"size(holder) = %zu",
sizeof(holder));
116 CHECK (0 == Dummy::checksum());
124 CHECK (0 == Dummy::checksum());
128 Dummy::activateCtorFailure();
131 create_contained_object (holder);
132 NOTREACHED (
"expect failure in ctor");
136 CHECK (0 != Dummy::checksum());
137 Dummy::checksum() -= val;
138 CHECK (0 == Dummy::checksum());
142 Dummy::activateCtorFailure(
false);
144 CHECK (0 == Dummy::checksum());
152 CHECK (0 == Dummy::checksum());
161 create_contained_object (holder);
163 long currSum = Dummy::checksum();
164 void* adr = holder.get();
169 CHECK (holder.get()==adr);
170 CHECK (Dummy::checksum()==currSum);
175 CHECK (holder.get()==adr);
176 CHECK (Dummy::checksum()==currSum);
178 create_contained_object (holder2);
180 CHECK (Dummy::checksum() != currSum);
181 currSum = Dummy::checksum();
186 CHECK (holder.get()==adr);
187 CHECK (Dummy::checksum()==currSum);
192 CHECK (Dummy::checksum()==currSum);
194 CHECK (0 == Dummy::checksum());
205 typedef std::map<int,HO> MapHO;
207 CHECK (0 == Dummy::checksum());
210 CHECK (isnil (maph));
212 for (uint i=0; i<100; ++i)
214 HO & contained = maph[i];
218 CHECK (0 == Dummy::checksum());
219 CHECK (!isnil (maph));
220 CHECK (100==maph.size());
222 for (uint i=0; i<100; ++i)
224 create_contained_object (maph[i]);
226 CHECK (0 < maph[i]->acc(12));
228 CHECK (100==maph.size());
229 CHECK (0 != Dummy::checksum());
232 long value55 = maph[55]->acc(0);
233 long currSum = Dummy::checksum();
235 CHECK (1 == maph.erase(55));
236 CHECK (Dummy::checksum() == currSum - value55);
237 CHECK (maph.size() == 99);
242 CHECK (maph.size() == 100);
244 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.
unittest helper code: test dummy objects to track instances.
Simple test class runner.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
A collection of frequently used helper functions to support unit testing.
A Dummy object for tests.
Lumiera error handling (C++ interface).