Update contrib.
6 #include "cppunit/cppunit_proxy.h"
8 #if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
15 class CopyTest : public CPPUNIT_NS::TestCase
17 CPPUNIT_TEST_SUITE(CopyTest);
18 CPPUNIT_TEST(copy_array);
19 CPPUNIT_TEST(copy_vector);
20 CPPUNIT_TEST(copy_insert);
21 CPPUNIT_TEST(copy_back);
22 CPPUNIT_TEST(copy_back_array);
23 CPPUNIT_TEST_SUITE_END();
30 void copy_back_array();
33 CPPUNIT_TEST_SUITE_REGISTRATION(CopyTest);
36 // tests implementation
38 void CopyTest::copy_array()
40 char string[23] = "A string to be copied.";
42 copy(string, string + 23, result);
43 CPPUNIT_ASSERT(!strncmp(string, result, 23));
46 void CopyTest::copy_vector()
49 for (int i = 0; (size_t)i < v1.size(); ++i)
52 vector<int> v2(v1.size());
53 copy(v1.begin(), v1.end(), v2.begin());
55 CPPUNIT_ASSERT( v2 == v1 );
58 void CopyTest::copy_insert() {
60 for (int loc = 0; (size_t)loc < v1.size(); ++loc)
63 insert_iterator<vector<int> > i(v2, v2.begin());
64 copy(v1.begin(), v1.end(), i);
66 CPPUNIT_ASSERT( v2 == v1 );
69 void CopyTest::copy_back()
72 for (int i = 0; (size_t)i < v1.size(); ++i)
74 vector<int> v2(v1.size());
75 copy_backward(v1.begin(), v1.end(), v2.end());
77 CPPUNIT_ASSERT( v2 == v1 );
80 void CopyTest::copy_back_array()
82 int numbers[5] = { 1, 2, 3, 4, 5 };
85 copy_backward(numbers, numbers + 5, (int*)result + 5);
86 CPPUNIT_ASSERT(result[0]==numbers[0]);
87 CPPUNIT_ASSERT(result[1]==numbers[1]);
88 CPPUNIT_ASSERT(result[2]==numbers[2]);
89 CPPUNIT_ASSERT(result[3]==numbers[3]);
90 CPPUNIT_ASSERT(result[4]==numbers[4]);