29 using std::unique_ptr;
38 const uint CHAN_COUNT = 30;
39 const uint NUM_FRAMES = 1000;
43 corruptMemory(
void* base, uint offset, uint count)
45 char* accessor =
reinterpret_cast<char*
> (base);
47 accessor[offset+count] =
rani(CHAR_MAX);
78 verifyFrameLifecycle();
90 CHECK (frame.isValid());
93 CHECK (not frame.isValid());
96 CHECK (frame.isValid());
98 CHECK (isSameObject(frame, frame.
data()));
110 CHECK (frameA == frameB);
111 CHECK (frameA != frameC);
112 CHECK (frameB != frameC);
114 CHECK (frameA.
data() == frameB.
data());
115 CHECK (frameA.
data() != frameC.
data());
116 for (uint i=0; i<frameA.
data().size(); ++i)
117 CHECK (frameA.
data()[i] == frameB.
data()[i]);
120 CHECK (frameA.
data()[ 8] == char(frameA.data64()[1]));
121 CHECK (frameA.
data()[16] == char(frameA.data64()[2]));
122 CHECK (frameA.
data()[24] == char(frameA.data64()[3]));
123 CHECK (frameA.
data()[32] == char(frameA.data64()[4]));
124 CHECK (frameA.
data().size() == 8*frameA.data64().size());
130 CHECK (frameA.isSane());
131 CHECK (frameB.isSane());
132 CHECK (frameC.isSane());
134 CHECK (frameA.isValid());
135 CHECK (frameB.isValid());
136 CHECK (frameC.isValid());
138 CHECK (frameA.isPristine());
139 CHECK (frameB.isPristine());
140 CHECK (frameC.isPristine());
142 void * frameMem = &frameB;
144 CHECK (frameA == frameMem);
145 corruptMemory (frameMem,20,5);
146 CHECK ( frameB.isSane());
147 CHECK (not frameB.isValid());
148 CHECK (not frameB.isPristine());
151 CHECK ( frameB.isSane());
152 CHECK ( frameB.isValid());
153 CHECK (not frameB.isPristine());
157 CHECK (frameB.isSane());
158 CHECK (frameA != frameB);
159 CHECK (frameA != frameC);
160 CHECK (frameB == frameC);
162 corruptMemory (frameMem, 0,
sizeof(
TestFrame));
163 CHECK (not frameB.isSane());
164 CHECK (not frameB.isValid());
166 , frameB.markChecksum() );
167 VERIFY_FAIL (
"target TestFrame already dead or unaccessible" 173 verifyFrameLifecycle()
175 CHECK (not TestFrame::isDead (
this));
176 CHECK (not TestFrame::isAlive (
this));
181 CHECK ( TestFrame::isAlive (frame));
182 CHECK (not frame->isDead());
183 CHECK ( frame->isAlive());
184 CHECK ( frame->isValid());
187 CHECK ( TestFrame::isDead (frame));
188 CHECK (not TestFrame::isAlive (frame));
189 CHECK ( frame->isValid());
190 CHECK ( frame->isSane());
201 unique_ptr<TestFrame> thisFrames[CHAN_COUNT];
202 unique_ptr<TestFrame> prevFrames[CHAN_COUNT];
204 for (uint i=0; i<CHAN_COUNT; ++i)
205 thisFrames[i].reset (
new TestFrame(0, i));
207 for (uint nr=1; nr<NUM_FRAMES; ++nr)
208 for (uint i=0; i<CHAN_COUNT; ++i)
210 thisFrames[i].swap (prevFrames[i]);
211 thisFrames[i].reset (
new TestFrame(nr, i));
212 CHECK (thisFrames[i]->isPristine());
213 CHECK (prevFrames[i]->isPristine());
214 CHECK (prevFrames[i]->isAlive());
216 CHECK (*thisFrames[i] != *prevFrames[i]);
218 for (uint j=0; j<i; ++j)
221 CHECK (*thisFrames[i] != *thisFrames[j]);
222 CHECK (*thisFrames[i] != *prevFrames[j]);
235 CHECK (frX.isPristine());
236 CHECK (frY.isPristine());
237 CHECK (frZ.isPristine());
243 CHECK (isSameObject (frX, frZ));
245 corruptMemory(&frZ,40,20);
246 CHECK (not frX.isPristine());
247 CHECK (not
testData(50,3).isPristine());
248 CHECK (
testData(51,3).isPristine());
249 CHECK (
testData(49,3).isPristine());
255 CHECK (
testData(50,3).isPristine());
256 CHECK (c !=
testData(49,3).data()[5]);
259 CHECK (not isSameObject(o,
testData(49,3)));
static bool isAlive(void *memLocation)
Helper to verify that a given memory location holds an active TestFrame instance (created, not yet destroyed)
Mock data frame for simulated rendering.
_Arr & data()
Array-style direct access to the payload data.
int rani(uint bound=_iBOUND())
Steam-Layer implementation namespace root.
Abstract Base Class for all testcases.
Simplistic test class runner.
void seedRand()
draw a new random seed from a common nucleus, and re-seed the default-Gen.
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.
static void reseed()
discard all cached #testData and recalibrate data generation
HashVal markChecksum()
recompute and store checksum based on current contents
Unit test helper to generate fake test data frames.
TestFrame & testData(uint seqNr, uint chanNr)
Helper to access a specific frame of test data at a fixed memory location.
#define VERIFY_FAIL(FAILURE_MSG, ERRONEOUS_STATEMENT)
Macro to verify that a statement indeed raises a std::exception, which additionally contains some FAI...
bool isSameObject(A const &a, B const &b)
compare plain object identity, based directly on the referee's memory identities. ...