Skip to content

Commit 451571d

Browse files
committed
Added test to testChannels unit-test to verify functionality of ChannelList::Iterator/ConstIterator
Signed-off-by: Aries Moczar <arcmantis@protulae.com>
1 parent 53a8942 commit 451571d

1 file changed

Lines changed: 66 additions & 0 deletions

File tree

src/test/OpenEXRTest/testChannels.cpp

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,79 @@ writeRead (
218218
cout << endl;
219219
}
220220

221+
void
222+
verifyIterators(void)
223+
{
224+
ChannelList l1,l2;
225+
226+
l1.insert("A", Channel(HALF));
227+
l1.insert("B", Channel(HALF));
228+
l1.insert("C", Channel(HALF));
229+
230+
l2 = l1;
231+
232+
auto it1 = l1.begin();
233+
const auto cit1 = l1.begin();
234+
235+
auto it2 = l2.begin();
236+
const auto cit2 = l2.begin();
237+
238+
// Test global '==' overloads
239+
assert(it1 == it1);
240+
assert(it1 == cit1);
241+
assert(cit1 == it1);
242+
assert(cit1 == cit1);
243+
244+
// Test global '!=' overloads
245+
assert(it1 != it2);
246+
assert(cit1 != it2);
247+
assert(it1 != cit2);
248+
assert(cit1 != cit2);
249+
250+
251+
while (it1 != l1.end())
252+
{
253+
// Test '*' overloads
254+
Channel& c = *it1;
255+
const Channel& cc = *it1;
256+
assert(c.type == HALF);
257+
assert(cc.type == HALF);
258+
259+
// Test '->' overload
260+
assert(it2->type == HALF);
261+
assert(cit2->type == HALF);
262+
263+
// Test pre/post '++' overloads
264+
it1++;
265+
++it2;
266+
}
267+
268+
assert(it1 == l1.end());
269+
assert(it2 == l2.end());
270+
271+
while (it1 != l1.begin())
272+
{
273+
274+
// Test pre/post '--' overloads
275+
it1--;
276+
--it2;
277+
}
278+
279+
assert(it1 == l1.begin());
280+
assert(it2 == l2.begin());
281+
}
282+
221283
} // namespace
222284

223285
void
224286
testChannels (const std::string& tempDir)
225287
{
226288
try
227289
{
290+
cout << "Testing ChannelList Iterator behavior" << endl;
291+
292+
verifyIterators ();
293+
228294
cout << "Testing filling of missing channels" << endl;
229295

230296
const int W = 117;

0 commit comments

Comments
 (0)