45 using Extents = ExtentFamily<int, 10>;
46 using Extent = Extents::Extent;
78 Extent& extent = *extents.begin();
79 CHECK (10 == extent.size());
81 int num = rand() % 1000;
84 CHECK (num == extent[2]);
85 CHECK (num+5 == extent[5]);
96 CHECK ( 0 == watch(extents).first());
97 CHECK ( 0 == watch(extents).last());
98 CHECK ( 0 == watch(extents).active());
99 CHECK ( 5 == watch(extents).size());
102 CHECK ( 0 == watch(extents).first());
103 CHECK ( 3 == watch(extents).last());
104 CHECK ( 3 == watch(extents).active());
105 CHECK ( 5 == watch(extents).size());
108 CHECK ( 2 == watch(extents).first());
109 CHECK ( 3 == watch(extents).last());
110 CHECK ( 1 == watch(extents).active());
111 CHECK ( 5 == watch(extents).size());
123 CHECK (isnil (extents));
124 Iter it = extents.begin();
129 CHECK (0 == it.getIndex());
130 CHECK (isSameObject(*it, *extents.begin()));
133 CHECK (10 == extent.size());
135 int num = rand() % 1000;
137 CHECK (num == extent[2]);
141 CHECK (1 == it.getIndex());
143 CHECK (not isSameObject(extent, nextEx));
144 CHECK (isSameObject(nextEx, *extents.last()));
145 nextEx[5] = extent[2] + 1;
146 CHECK (num == extent[2]);
147 CHECK (num+1 == nextEx[5]);
150 CHECK (it == extents.end());
156 it = extents.begin();
157 CHECK (isSameObject(*it, extent));
158 CHECK ((*it)[2] == num);
160 CHECK (isSameObject(*it, nextEx));
161 CHECK ((*it)[5] == num+1);
175 Probe() : val(1 + rand() % 1000) { }
176 ~Probe() { val = 0; }
181 SpecialExtents spex{3};
183 CHECK ( 0 == watch(spex).first());
184 CHECK ( 2 == watch(spex).last());
187 auto& extent = *spex.begin();
188 for (Probe& probe : extent)
191 auto calcChecksum = [](SpecialExtents::Extent& extent) ->
size_t 194 for (Probe& probe : extent)
199 size_t checksum = calcChecksum (*spex.begin());
205 CHECK ( 1 == watch(spex).first());
206 CHECK ( 2 == watch(spex).last());
209 CHECK (not isSameObject (extent, *spex.begin()));
210 size_t checkSecond = calcChecksum (*spex.begin());
211 CHECK (checkSecond != checksum);
214 CHECK (checksum == calcChecksum (extent));
218 CHECK ( 2 == watch(spex).first());
219 CHECK ( 2 == watch(spex).last());
221 CHECK ( 2 == watch(spex).first());
222 CHECK ( 1 == watch(spex).last());
224 auto iter = spex.begin();
225 CHECK ( 2 ==
iter.getIndex());
227 CHECK ( 0 == iter.getIndex());
228 CHECK (isSameObject(*iter, extent));
232 CHECK (checksum == calcChecksum (extent));
249 auto snapshotAdr = [](
Extents& extents)
251 auto takeAdr = [](
auto& x){
return &*x; };
252 return explore(extents).transform(takeAdr).effuse();
254 auto verifyAdr = [](
auto snapshot,
auto it)
256 for (
auto oldAddr : snapshot)
258 if (not isSameObject(*oldAddr, *it))
267 CHECK ( extents.empty());
268 CHECK ( 0 == watch(extents).first());
269 CHECK ( 0 == watch(extents).last());
270 CHECK ( 0 == watch(extents).active());
271 CHECK ( 5 == watch(extents).size());
274 CHECK ( 0 == watch(extents).first());
275 CHECK ( 4 == watch(extents).last());
276 CHECK ( 4 == watch(extents).active());
277 CHECK ( 5 == watch(extents).size());
279 auto snapshot = snapshotAdr(extents);
280 CHECK (4 == snapshot.size());
283 CHECK ( 0 == watch(extents).first());
284 CHECK ( 5 == watch(extents).last());
285 CHECK ( 5 == watch(extents).active());
286 CHECK (10 == watch(extents).size());
287 CHECK (verifyAdr (snapshot, extents.begin()));
290 CHECK ( 3 == watch(extents).first());
291 CHECK ( 5 == watch(extents).last());
292 CHECK ( 2 == watch(extents).active());
293 CHECK (10 == watch(extents).size());
294 CHECK (isSameObject (*extents.begin(), *snapshot.back()));
297 CHECK ( 3 == watch(extents).first());
298 CHECK ( 1 == watch(extents).last());
299 CHECK ( 8 == watch(extents).active());
300 CHECK (10 == watch(extents).size());
301 snapshot = snapshotAdr (extents);
302 CHECK (8 == snapshot.size());
305 CHECK ( 8 == watch(extents).first());
306 CHECK ( 3 == watch(extents).last());
307 CHECK (10 == watch(extents).active());
308 CHECK (15 == watch(extents).size());
309 CHECK (verifyAdr (snapshot, extents.begin()));
312 CHECK ( 3 == watch(extents).first());
313 CHECK ( 3 == watch(extents).last());
314 CHECK ( 0 == watch(extents).active());
315 CHECK (15 == watch(extents).size());
318 CHECK ( 3 == watch(extents).first());
319 CHECK ( 0 == watch(extents).last());
320 CHECK (12 == watch(extents).active());
321 CHECK (15 == watch(extents).size());
324 CHECK (14 == watch(extents).first());
325 CHECK ( 0 == watch(extents).last());
326 CHECK ( 1 == watch(extents).active());
327 CHECK (15 == watch(extents).size());
329 CHECK (14 == extents.begin().getIndex());
330 snapshot = snapshotAdr (extents);
331 CHECK (1 == snapshot.size());
332 CHECK (isSameObject (*extents.begin(), *snapshot.front()));
335 CHECK (19 == watch(extents).first());
336 CHECK (14 == watch(extents).last());
337 CHECK (15 == watch(extents).active());
338 CHECK (20 == watch(extents).size());
340 CHECK (19 == extents.begin().getIndex());
341 CHECK (isSameObject (*extents.begin(), *snapshot.front()));
logical structure of a memory Extent
auto explore(IT &&srcSeq)
start building a IterExplorer by suitably wrapping the given iterable source.
void openNew(size_t cnt=1)
claim next cnt extents, possibly allocate.
Abstract Base Class for all testcases.
Simple test class runner.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
Memory manager to provide a sequence of Extents for cyclic usage.
Memory management scheme for cyclically used memory extents.
Decorator-Adapter to make a »state core« iterable as Lumiera Forward Iterator.
Building tree expanding and backtracking evaluations within hierarchical scopes.
lib::IterableDecorator< Extent, IdxLink > iterator
allow transparent iteration of Extents, with the ability to expand storage
Vault-Layer implementation namespace root.
bool isSameObject(A const &a, B const &b)
compare plain object identity, bypassing any custom comparison operators.