Skip to content

Commit 652aa0c

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 2041f64 commit 652aa0c

2 files changed

Lines changed: 70 additions & 1 deletion

File tree

src/lib/OpenEXR/ImfChannelList.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ inline bool
545545
operator!= (
546546
const ChannelList::ConstIterator& x, ChannelList::Iterator& y)
547547
{
548-
return !(x._i == y,_i);
548+
return !(x._i == y._i);
549549
}
550550

551551
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT

src/test/OpenEXRTest/testChannels.cpp

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

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

223288
void
224289
testChannels (const std::string& tempDir)
225290
{
226291
try
227292
{
293+
cout << "Testing ChannelList Iterator behavior" << endl;
294+
295+
verifyIterators ();
296+
228297
cout << "Testing filling of missing channels" << endl;
229298

230299
const int W = 117;

0 commit comments

Comments
 (0)