38 using std::unique_ptr;
47 const uint CHAN_COUNT = 30;
48 const uint NUM_FRAMES = 1000;
52 corruptMemory(
void* base, uint offset, uint count)
54 char* accessor =
reinterpret_cast<char*
> (base);
56 accessor[offset+count] = rand() % CHAR_MAX;
82 verifyBasicProperties();
83 verifyFrameLifecycle();
90 verifyBasicProperties()
98 CHECK (frameA == frameB);
99 CHECK (frameA != frameC);
100 CHECK (frameB != frameC);
106 CHECK (frameA.isSane());
107 CHECK (frameB.isSane());
108 CHECK (frameC.isSane());
110 void * frameMem = &frameB;
112 CHECK (frameA == frameMem);
113 corruptMemory(frameMem,20,5);
114 CHECK (!frameB.isSane());
118 CHECK (frameB.isSane());
119 CHECK (frameA != frameB);
120 CHECK (frameA != frameC);
121 CHECK (frameB == frameC);
126 verifyFrameLifecycle()
128 CHECK (!TestFrame::isDead (
this));
129 CHECK (!TestFrame::isAlive (
this));
134 CHECK ( TestFrame::isAlive (frame));
135 CHECK (!frame->isDead());
136 CHECK (frame->isAlive());
137 CHECK (frame->isSane());
140 CHECK ( TestFrame::isDead (frame));
141 CHECK (!TestFrame::isAlive (frame));
152 unique_ptr<TestFrame> thisFrames[CHAN_COUNT];
153 unique_ptr<TestFrame> prevFrames[CHAN_COUNT];
155 for (uint i=0; i<CHAN_COUNT; ++i)
156 thisFrames[i].reset (
new TestFrame(0, i));
158 for (uint nr=1; nr<NUM_FRAMES; ++nr)
159 for (uint i=0; i<CHAN_COUNT; ++i)
161 thisFrames[i].swap (prevFrames[i]);
162 thisFrames[i].reset (
new TestFrame(nr, i));
163 CHECK (thisFrames[i]->isSane());
164 CHECK (prevFrames[i]->isSane());
165 CHECK (prevFrames[i]->isAlive());
167 CHECK (*thisFrames[i] != *prevFrames[i]);
169 for (uint j=0; j<i; ++j)
172 CHECK (*thisFrames[i] != *thisFrames[j]);
173 CHECK (*thisFrames[i] != *prevFrames[j]);
186 CHECK (frX.isSane());
187 CHECK (frY.isSane());
188 CHECK (frZ.isSane());
194 CHECK (isSameObject (frX, frZ));
196 corruptMemory(&frZ,40,20);
197 CHECK (!frX.isSane());
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.
TestFrame & testData(uint seqNr)
Helper to access a specific frame of test data at a fixed memory location.
Steam-Layer implementation namespace root.
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...
void resetTestFrames()
discards all the TestFrame instances and initialises an empty table of test frames ...
Unit test helper to generate fake test data frames.
bool isSameObject(A const &a, B const &b)
compare plain object identity, bypassing any custom comparison operators.