39 virtual int op(
int i)
const =0;
47 Sub1 (
int o=1) : offs_(o) {}
49 int op (
int i)
const {
return i+offs_; }
55 Sub2() : letterz_(
"ABCDEFGHIJKLMNOPQRSTUVWXYZ") {}
57 int op (
int i)
const {
return (
int)letterz_[i % 26]; }
66 Sub3(
int id) : id_(
id)
77 int op (
int i)
const {
return i + id_; }
81 long Sub3::trigger = -1;
115 checkTable_inplaceCreation();
116 checkTable_errorHandling();
124 vector<Sub2> subz(10);
129 CHECK (subWrap.size()==subz.size());
131 for (
size_t i=0; i<rArr.size(); ++i)
133 CHECK (&rArr[i] == &subz[i]);
134 CHECK (rArr[i].op(i) == subz[i].op(i));
143 vector<Sub2> & vect (subz);
146 CHECK (vect.size()==subz.size());
148 for (
size_t i=0; i<rArr.size(); ++i)
150 CHECK (&rArr[i] == &vect[i]);
151 CHECK (rArr[i].op(i) == vect[i].op(i));
156 #define ADR(OBJ) (ulong)&(OBJ) 164 CHECK (
sizeof(tab) >= 20 *
sizeof(Sub1));
165 CHECK (ADR(tab) < ADR(tab[19]) && ADR(tab[19]) < ADR(tab) +
sizeof(tab));
169 CHECK (20 == tab.size());
171 for (
size_t i=0; i<rArr.size(); ++i)
173 CHECK (i*
sizeof(Sub1) == ADR(rArr[i]) - ADR(rArr[0]) );
174 CHECK (
int(i+1) == rArr[i].op(i));
182 Fac ( ) : offset_ (0) {}
184 void operator() (
void* place)
187 new(place) SUB (offset_++);
193 checkTable_inplaceCreation()
198 CHECK (30 == tab.size());
199 for (
size_t i=0; i<rArr.size(); ++i)
200 CHECK (
int(i+i) == rArr[i].op(i));
205 checkTable_errorHandling()
207 for (uint i=0; i<500; ++i)
210 Sub3::trigger =
rani(50);
216 CHECK (Sub3::sum == (29+1)*29/2);
218 CHECK (Sub3::sum == 0);
223 CHECK (
id == Sub3::trigger);
224 CHECK (Sub3::sum ==
id);
Abstraction: Array of const references.
#define INSTANCEOF(CLASS, EXPR)
shortcut for subclass test, intended for assertions only.
int rani(uint bound=_iBOUND())
TestFactory theFact
Factory instance for the tests...
Implementation namespace for support and library code.
RefArray implementation based on a fixed size array, i.e.
Simplistic test class runner.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
Some (library-) implementations of the RefArray interface.
< fabricating a series of subclass instances with varying ctor parameter
This variation of the wrapper actually is a vector, but can act as a RefArray.
Wrap a vector holding objects of a subtype and provide array-like access using the interface type...