Update contrib.
5 #include "cppunit/cppunit_proxy.h"
7 #if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
14 class UnaryTest : public CPPUNIT_NS::TestCase
16 CPPUNIT_TEST_SUITE(UnaryTest);
17 #if !defined (STLPORT) || defined (_STLP_NO_EXTENSIONS)
20 CPPUNIT_TEST(ucompos1);
21 CPPUNIT_TEST(ucompos2);
23 CPPUNIT_TEST(unegate1);
24 CPPUNIT_TEST(unegate2);
25 #if defined (STLPORT) && !defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
28 CPPUNIT_TEST(unegate3);
29 CPPUNIT_TEST_SUITE_END();
39 CPPUNIT_TEST_SUITE_REGISTRATION(UnaryTest);
42 // tests implementation
44 void UnaryTest::unegate1()
46 int array [3] = { 1, 2, 3 };
47 //unary_negate<odd>::argument_type arg_val = 0;
48 int* p = find_if((int*)array, (int*)array + 3, unary_negate<odd>(odd()));
49 CPPUNIT_ASSERT((p != array + 3));
50 CPPUNIT_ASSERT(*p==2);
52 void UnaryTest::unegate2()
54 int array [3] = { 1, 2, 3 };
55 int* p = find_if((int*)array, (int*)array + 3, not1(odd()));
56 CPPUNIT_ASSERT(p != array + 3);
57 CPPUNIT_ASSERT(*p==2);
60 bool test_func(int param) {
63 void UnaryTest::unegate3()
65 #if !defined (STLPORT) || defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
66 int array [3] = { 1, 2, 3 };
67 int* p = find_if((int*)array, (int*)array + 3, not1(ptr_fun(test_func)));
68 CPPUNIT_ASSERT(p != array + 3);
69 CPPUNIT_ASSERT(*p==3);
73 void UnaryTest::ucompos1()
75 #if defined (STLPORT) && !defined (_STLP_NO_EXTENSIONS)
76 int input [3] = { -1, -4, -16 };
79 transform((int*)input, (int*)input + 3, output, unary_compose<square_root, negate<int> >(square_root(), negate<int>()));
81 CPPUNIT_ASSERT(output[0]==1);
82 CPPUNIT_ASSERT(output[1]==2);
83 CPPUNIT_ASSERT(output[2]==4);
86 void UnaryTest::ucompos2()
88 #if defined (STLPORT) && !defined (_STLP_NO_EXTENSIONS)
89 int input [3] = { -1, -4, -16 };
92 transform((int*)input, (int*)input + 3, output, compose1(square_root(), negate<int>()));
94 CPPUNIT_ASSERT(output[0]==1);
95 CPPUNIT_ASSERT(output[1]==2);
96 CPPUNIT_ASSERT(output[2]==4);