48 virtual int op(
int i)
const =0;
56 Sub1 (
int o=1) : offs_(o) {}
58 int op (
int i)
const {
return i+offs_; }
64 Sub2() : letterz_(
"ABCDEFGHIJKLMNOPQRSTUVWXYZ") {}
66 int op (
int i)
const {
return (
int)letterz_[i % 26]; }
75 Sub3(
int id) : id_(
id)
86 int op (
int i)
const {
return i + id_; }
90 long Sub3::trigger = -1;
122 checkTable_inplaceCreation();
123 checkTable_errorHandling();
131 vector<Sub2> subz(10);
136 CHECK (subWrap.size()==subz.size());
138 for (
size_t i=0; i<rArr.size(); ++i)
140 CHECK (&rArr[i] == &subz[i]);
141 CHECK (rArr[i].op(i) == subz[i].op(i));
150 vector<Sub2> & vect (subz);
153 CHECK (vect.size()==subz.size());
155 for (
size_t i=0; i<rArr.size(); ++i)
157 CHECK (&rArr[i] == &vect[i]);
158 CHECK (rArr[i].op(i) == vect[i].op(i));
163 #define ADR(OBJ) (ulong)&(OBJ) 171 CHECK (
sizeof(tab) >= 20 *
sizeof(Sub1));
172 CHECK (ADR(tab) < ADR(tab[19]) && ADR(tab[19]) < ADR(tab) +
sizeof(tab));
176 CHECK (20 == tab.size());
178 for (
size_t i=0; i<rArr.size(); ++i)
180 CHECK (i*
sizeof(Sub1) == ADR(rArr[i]) - ADR(rArr[0]) );
181 CHECK (
int(i+1) == rArr[i].op(i));
189 Fac ( ) : offset_ (0) {}
191 void operator() (
void* place)
194 new(place) SUB (offset_++);
200 checkTable_inplaceCreation()
205 CHECK (30 == tab.size());
206 for (
size_t i=0; i<rArr.size(); ++i)
207 CHECK (
int(i+i) == rArr[i].op(i));
212 checkTable_errorHandling()
214 for (uint i=0; i<500; ++i)
217 Sub3::trigger = (rand() % 50);
223 CHECK (Sub3::sum == (29+1)*29/2);
225 CHECK (Sub3::sum == 0);
230 CHECK (
id == Sub3::trigger);
231 CHECK (Sub3::sum ==
id);
Abstraction: Array of const references.
#define INSTANCEOF(CLASS, EXPR)
shortcut for subclass test, intended for assertions only.
TestFactory theFact
Factory instance for the tests...
Implementation namespace for support and library code.
RefArray implementation based on a fixed size array, i.e.
Simple 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...