#include "testUtils.h" #include using namespace irr; using namespace core; // list has no operator== currently so we have to check manually // TODO: Add an operator== to core::list and the kick this function out template static bool compareLists(const core::list & a, const core::list & b) { if ( a.size() != b.size() ) return false; // can't test allocator because we have no access to it here typename core::list::ConstIterator iterA = a.begin(); typename core::list::ConstIterator iterB = b.begin(); for ( ; iterA != a.end(); ++iterA, ++iterB ) { if ( (*iterA) != (*iterB) ) return false; } return true; } // Make sure that we can get a const iterator from a non-const list template static void constIteratorCompileTest(core::list & a) { typename core::list::ConstIterator iterA = a.begin(); while (iterA != a.end() ) { ++iterA; } } static bool testSwap() { bool result = true; core::list list1, list2, copy1, copy2; for ( int i=0; i<99; ++i ) { list1.push_back(i); if ( i < 10 ) // we want also different container sizes i < 50 ) list2.push_back(99-i); } copy1 = list1; copy2 = list2; list1.swap(list2); result &= compareLists(list1, copy2); result &= compareLists(list2, copy1); assert_log( result ); return result; } // Test the functionality of core::list bool testIrrList(void) { bool success = true; core::list compileThisList; constIteratorCompileTest(compileThisList); success &= testSwap(); if(success) logTestString("\nAll tests passed\n"); else logTestString("\nFAIL!\n"); return success; }