diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2009-02-12 13:44:34 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2009-02-12 13:44:34 +0000 |
| commit | b8b6b5c56890122c182c035406457ae7a5791f6a (patch) | |
| tree | d14084200913324948bdf5485c176e71d6717abd /test/array_funTest.cc | |
| parent | a73ef15904a8428d7e979aef419111f30fc12800 (diff) | |
2009-02-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added array_wrapper template.
* src/array_fun.h
* test/array_funTest.cc
Diffstat (limited to 'test/array_funTest.cc')
| -rw-r--r-- | test/array_funTest.cc | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/array_funTest.cc b/test/array_funTest.cc index 6e474fcc..be9b0162 100644 --- a/test/array_funTest.cc +++ b/test/array_funTest.cc @@ -12,6 +12,7 @@ class array_funTest:public CppUnit::TestFixture { CPPUNIT_TEST(testArray_and); CPPUNIT_TEST(testArrayLength); CPPUNIT_TEST(testArrayPtr); + CPPUNIT_TEST(testArrayWrapper); CPPUNIT_TEST_SUITE_END(); public: @@ -21,6 +22,7 @@ public: void testArray_and(); void testArrayLength(); void testArrayPtr(); + void testArrayWrapper(); struct X{ int m; @@ -109,4 +111,25 @@ void array_funTest::testArrayPtr() arrayPtrConstCast(ax); } +static void arrayWrapperConst(const array_wrapper<int, 10>& array) +{ + CPPUNIT_ASSERT_EQUAL(9, array[9]); +} + +void array_funTest::testArrayWrapper() +{ + array_wrapper<int, 10> a1; + CPPUNIT_ASSERT_EQUAL((size_t)10, a1.size()); + for(size_t i = 0; i < a1.size(); ++i) { + a1[i] = i; + } + CPPUNIT_ASSERT_EQUAL(9, a1[9]); + array_wrapper<int, 10> a2 = a1; + CPPUNIT_ASSERT_EQUAL(9, a2[9]); + + array_wrapper<struct X, 10> x1; + arrayPtrCast(x1); + arrayPtrConstCast(x1); +} + } // namespace aria2 |
