1 #include "testUtils.h"
\r
2 #include <irrlicht.h>
\r
5 using namespace core;
\r
7 // list has no operator== currently so we have to check manually
\r
8 // TODO: Add an operator== to core::list and the kick this function out
\r
9 template <typename T>
\r
10 static bool compareLists(const core::list<T> & a, const core::list<T> & b)
\r
12 if ( a.size() != b.size() )
\r
14 // can't test allocator because we have no access to it here
\r
15 typename core::list<T>::ConstIterator iterA = a.begin();
\r
16 typename core::list<T>::ConstIterator iterB = b.begin();
\r
17 for ( ; iterA != a.end(); ++iterA, ++iterB )
\r
19 if ( (*iterA) != (*iterB) )
\r
25 // Make sure that we can get a const iterator from a non-const list
\r
26 template <typename T>
\r
27 static void constIteratorCompileTest(core::list<T> & a)
\r
29 typename core::list<T>::ConstIterator iterA = a.begin();
\r
30 while (iterA != a.end() )
\r
36 static bool testSwap()
\r
40 core::list<int> list1, list2, copy1, copy2;
\r
41 for ( int i=0; i<99; ++i )
\r
44 if ( i < 10 ) // we want also different container sizes i < 50 )
\r
45 list2.push_back(99-i);
\r
52 result &= compareLists<int>(list1, copy2);
\r
53 result &= compareLists<int>(list2, copy1);
\r
55 assert_log( result );
\r
60 // Test the functionality of core::list
\r
61 bool testIrrList(void)
\r
63 bool success = true;
\r
65 core::list<int> compileThisList;
\r
66 constIteratorCompileTest(compileThisList);
\r
68 success &= testSwap();
\r
71 logTestString("\nAll tests passed\n");
\r
73 logTestString("\nFAIL!\n");
\r