Update contrib.
6 #include "cppunit/cppunit_proxy.h"
8 #if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
15 class TransformTest : public CPPUNIT_NS::TestCase
17 CPPUNIT_TEST_SUITE(TransformTest);
18 CPPUNIT_TEST(trnsfrm1);
19 CPPUNIT_TEST(trnsfrm2);
20 CPPUNIT_TEST(self_str);
21 CPPUNIT_TEST_SUITE_END();
28 static int negate_int(int a_) {
31 static char map_char(char a_, int b_) {
34 static char shift( char c ) {
35 return char(((int)c + 1) % 256);
39 CPPUNIT_TEST_SUITE_REGISTRATION(TransformTest);
42 // tests implementation
44 void TransformTest::trnsfrm1()
46 int numbers[6] = { -5, -1, 0, 1, 6, 11 };
49 transform((int*)numbers, (int*)numbers + 6, (int*)result, negate_int);
51 CPPUNIT_ASSERT(result[0]==5);
52 CPPUNIT_ASSERT(result[1]==1);
53 CPPUNIT_ASSERT(result[2]==0);
54 CPPUNIT_ASSERT(result[3]==-1);
55 CPPUNIT_ASSERT(result[4]==-6);
56 CPPUNIT_ASSERT(result[5]==-11);
58 void TransformTest::trnsfrm2()
61 int trans[] = {-11, 4, -6, -6, -18, 0, 18, -14, 6, 0, -1, -59};
63 int trans[] = {-4, 4, -6, -6, -10, 0, 10, -6, 6, 0, -1, -77};
65 char n[] = "Larry Mullen";
66 const size_t count = ::strlen(n);
69 transform(n, n + count, trans, back_inserter(res), map_char);
70 CPPUNIT_ASSERT( res == "Hello World!" )
73 void TransformTest::self_str()
75 string s( "0123456789abcdefg" );
76 string r( "123456789:bcdefgh" );
77 transform( s.begin(), s.end(), s.begin(), shift );
78 CPPUNIT_ASSERT( s == r );