Update contrib.
5 #include "cppunit/cppunit_proxy.h"
7 #if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
14 class Ptr2Test : public CPPUNIT_NS::TestCase
16 CPPUNIT_TEST_SUITE(Ptr2Test);
17 CPPUNIT_TEST(ptrbin1);
18 CPPUNIT_TEST(ptrbin2);
21 CPPUNIT_TEST_SUITE_END();
30 CPPUNIT_TEST_SUITE_REGISTRATION(Ptr2Test);
33 // tests implementation
35 static int sum(int x_, int y_)
43 void Ptr2Test::ptrbin1()
45 int input1 [4] = { 7, 2, 3, 5 };
46 int input2 [4] = { 1, 5, 5, 8 };
49 transform((int*)input1, (int*)input1 + 4, (int*)input2, (int*)output, pointer_to_binary_function<int, int, int>(sum));
51 CPPUNIT_ASSERT(output[0]==8);
52 CPPUNIT_ASSERT(output[1]==7);
53 CPPUNIT_ASSERT(output[2]==8);
54 CPPUNIT_ASSERT(output[3]==13);
56 void Ptr2Test::ptrbin2()
58 int input1 [4] = { 7, 2, 3, 5 };
59 int input2 [4] = { 1, 5, 5, 8 };
62 transform((int*)input1, (int*)input1 + 4, (int*)input2, (int*)output, ptr_fun(sum));
64 CPPUNIT_ASSERT(output[0]==8);
65 CPPUNIT_ASSERT(output[1]==7);
66 CPPUNIT_ASSERT(output[2]==8);
67 CPPUNIT_ASSERT(output[3]==13);
69 void Ptr2Test::ptrun1()
71 int array [3] = { 1, 2, 3 };
73 int* p = find_if((int*)array, (int*)array + 3, pointer_to_unary_function<int, bool>(even));
74 CPPUNIT_ASSERT(p != array+3);
75 CPPUNIT_ASSERT(*p==2);
77 void Ptr2Test::ptrun2()
79 int array [3] = { 1, 2, 3 };
81 int* p = find_if((int*)array, (int*)array + 3, ptr_fun(even));
82 CPPUNIT_ASSERT(p != array+3);
83 CPPUNIT_ASSERT(*p==2);