From 20c4be47a39b6d8e7bb1587a8a4630bb2e620f54 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Fri, 26 May 2006 17:18:23 +0000 Subject: add functions for reverse iteration of Common::List svn-id: r22665 --- test/common/list.h | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'test/common') diff --git a/test/common/list.h b/test/common/list.h index 31ff7af399..26709b061b 100644 --- a/test/common/list.h +++ b/test/common/list.h @@ -103,4 +103,47 @@ class ListTestSuite : public CxxTest::TestSuite ++iter; TS_ASSERT( iter == container.end() ); } + + void test_reverse( void ) + { + Common::List container; + Common::List::iterator iter; + + // Fill the container with some random data + container.push_back(17); + container.push_back(33); + container.push_back(-11); + + iter = container.reverse_begin(); + TS_ASSERT( iter != container.end() ); + + + TS_ASSERT( *iter == -11 ); + --iter; + TS_ASSERT( iter != container.end() ); + + TS_ASSERT( *iter == 33 ); + --iter; + TS_ASSERT( iter != container.end() ); + + TS_ASSERT( *iter == 17 ); + --iter; + TS_ASSERT( iter == container.end() ); + + iter = container.reverse_begin(); + + iter = container.reverse_erase(iter); + TS_ASSERT( iter != container.end() ); + TS_ASSERT( *iter == 33 ); + + iter = container.reverse_erase(iter); + TS_ASSERT( iter != container.end() ); + TS_ASSERT( *iter == 17 ); + + iter = container.reverse_erase(iter); + TS_ASSERT( iter == container.end() ); + + TS_ASSERT( container.begin() == container.end() ); + TS_ASSERT( container.reverse_begin() == container.end() ); + } }; -- cgit v1.2.3