From e579f91b5c1b0949954037acf5bb4b364bfeb2b5 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Mon, 27 Apr 2009 14:23:20 +0000 Subject: COMMON: Made sure Common::List and Common::array each have all front/back/push_back/push_front, as have their STL counterparts svn-id: r40163 --- test/common/array.h | 20 ++++++++++++++++++++ test/common/list.h | 19 +++++++++++++++++++ test/common/queue.h | 25 +++++++++++++------------ 3 files changed, 52 insertions(+), 12 deletions(-) (limited to 'test') diff --git a/test/common/array.h b/test/common/array.h index 52c6529bbc..de3f0decc5 100644 --- a/test/common/array.h +++ b/test/common/array.h @@ -164,4 +164,24 @@ class ArrayTestSuite : public CxxTest::TestSuite TS_ASSERT_EQUALS( array2.size(), (unsigned int)3 ); } + + void test_front_back_push_pop() { + Common::Array container; + + container.push_back( 42); + container.push_back(-23); + + TS_ASSERT_EQUALS(container.front(), 42); + TS_ASSERT_EQUALS(container.back(), -23); + + container.front() = -17; + container.back() = 163; + TS_ASSERT_EQUALS(container.front(), -17); + TS_ASSERT_EQUALS(container.back(), 163); + + container.pop_back(); + TS_ASSERT_EQUALS(container.front(), -17); + TS_ASSERT_EQUALS(container.back(), -17); + } + }; diff --git a/test/common/list.h b/test/common/list.h index 629150d554..67db1e1a42 100644 --- a/test/common/list.h +++ b/test/common/list.h @@ -168,4 +168,23 @@ class ListTestSuite : public CxxTest::TestSuite TS_ASSERT( container.begin() == container.end() ); TS_ASSERT( container.reverse_begin() == container.end() ); } + + void test_front_back_push_pop() { + Common::List container; + + container.push_back( 42); + container.push_back(-23); + + TS_ASSERT_EQUALS(container.front(), 42); + TS_ASSERT_EQUALS(container.back(), -23); + + container.front() = -17; + container.back() = 163; + TS_ASSERT_EQUALS(container.front(), -17); + TS_ASSERT_EQUALS(container.back(), 163); + + container.pop_front(); + TS_ASSERT_EQUALS(container.front(), 163); + TS_ASSERT_EQUALS(container.back(), 163); + } }; diff --git a/test/common/queue.h b/test/common/queue.h index 505e056722..cadb3979d7 100644 --- a/test/common/queue.h +++ b/test/common/queue.h @@ -32,22 +32,23 @@ public: TS_ASSERT_EQUALS(queue.size(), 2); } - void test_front_back_pop() { - Common::Queue queue; + void test_front_back_push_pop() { + Common::Queue container; - queue.push( 42); - queue.push(-23); + container.push( 42); + container.push(-23); - TS_ASSERT_EQUALS(queue.front(), 42); - TS_ASSERT_EQUALS(queue.back(), -23); + TS_ASSERT_EQUALS(container.front(), 42); + TS_ASSERT_EQUALS(container.back(), -23); - queue.front() = -23; - queue.back() = 42; - TS_ASSERT_EQUALS(queue.front(), -23); - TS_ASSERT_EQUALS(queue.back(), 42); + container.front() = -17; + container.back() = 163; + TS_ASSERT_EQUALS(container.front(), -17); + TS_ASSERT_EQUALS(container.back(), 163); - queue.pop(); - TS_ASSERT_EQUALS(queue.front(), 42); + container.pop(); + TS_ASSERT_EQUALS(container.front(), 163); + TS_ASSERT_EQUALS(container.back(), 163); } void test_assign() { -- cgit v1.2.3