ReactOS 0.4.15-dev-8100-g1887773
unary_test.cpp
Go to the documentation of this file.
1#include <vector>
2#include "unary.h"
3#include <algorithm>
4
6
7#if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
8using namespace std;
9#endif
10
11//
12// TestCase class
13//
14class UnaryTest : public CPPUNIT_NS::TestCase
15{
17#if !defined (STLPORT) || defined (_STLP_NO_EXTENSIONS)
19#endif
25#if defined (STLPORT) && !defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
27#endif
30
31protected:
32 void ucompos1();
33 void ucompos2();
34 void unegate1();
35 void unegate2();
36 void unegate3();
37};
38
40
41//
42// tests implementation
43//
45{
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);
51}
53{
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);
58}
59
60bool test_func(int param) {
61 return param < 3;
62}
64{
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);
70#endif
71}
72
74{
75#if defined (STLPORT) && !defined (_STLP_NO_EXTENSIONS)
76 int input [3] = { -1, -4, -16 };
77
78 double output[3];
80
81 CPPUNIT_ASSERT(output[0]==1);
82 CPPUNIT_ASSERT(output[1]==2);
83 CPPUNIT_ASSERT(output[2]==4);
84#endif
85}
87{
88#if defined (STLPORT) && !defined (_STLP_NO_EXTENSIONS)
89 int input [3] = { -1, -4, -16 };
90
91 double output [3];
92 transform((int*)input, (int*)input + 3, output, compose1(square_root(), negate<int>()));
93
94 CPPUNIT_ASSERT(output[0]==1);
95 CPPUNIT_ASSERT(output[1]==2);
96 CPPUNIT_ASSERT(output[2]==4);
97#endif
98}
_STLP_MOVE_TO_STD_NAMESPACE _InputIter find_if(_InputIter __first, _InputIter __last, _Predicate __pred)
Definition: _algobase.c:214
unary_compose< _Operation1, _Operation2 > compose1(const _Operation1 &__fn1, const _Operation2 &__fn2)
Definition: _function.h:285
unary_negate< _Predicate > not1(const _Predicate &__pred)
Definition: _function.h:154
pointer_to_unary_function< _Arg, _Result > ptr_fun(_Result(*__f)(_Arg))
void unegate2()
Definition: unary_test.cpp:52
void unegate1()
Definition: unary_test.cpp:44
CPPUNIT_TEST(ucompos2)
CPPUNIT_TEST_SUITE(UnaryTest)
void ucompos1()
Definition: unary_test.cpp:73
void ucompos2()
Definition: unary_test.cpp:86
CPPUNIT_TEST(unegate2)
CPPUNIT_TEST(unegate1)
CPPUNIT_TEST_SUITE_END()
CPPUNIT_TEST(ucompos1)
CPPUNIT_TEST(unegate3)
void unegate3()
Definition: unary_test.cpp:63
#define CPPUNIT_TEST_SUITE_REGISTRATION(X)
Definition: cppunit_mini.h:193
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
GLuint GLenum GLenum transform
Definition: glext.h:9407
GLfloat GLfloat p
Definition: glext.h:8902
GLfloat param
Definition: glext.h:5796
GLenum GLenum GLenum input
Definition: glext.h:9031
Definition: features.h:417
Definition: unary.h:11
bool test_func(int param)
Definition: unary_test.cpp:60