ReactOS  0.4.14-dev-52-g6116262
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)
8 using namespace std;
9 #endif
10 
11 //
12 // TestCase class
13 //
14 class UnaryTest : public CPPUNIT_NS::TestCase
15 {
17 #if !defined (STLPORT) || defined (_STLP_NO_EXTENSIONS)
19 #endif
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)
27 #endif
28  CPPUNIT_TEST(unegate3);
30 
31 protected:
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 
60 bool 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 }
void unegate1()
Definition: unary_test.cpp:44
static UCHAR ULONG UCHAR ULONG UCHAR * output
Definition: bcrypt.c:29
void ucompos2()
Definition: unary_test.cpp:86
#define CPPUNIT_TEST_SUITE(X)
Definition: cppunit_mini.h:142
CPPUNIT_TEST_SUITE_REGISTRATION(UnaryTest)
pointer_to_unary_function< _Arg, _Result > ptr_fun(_Result(*__f)(_Arg))
#define CPPUNIT_TEST(X)
Definition: cppunit_mini.h:182
Definition: features.h:417
unary_compose< _Operation1, _Operation2 > compose1(const _Operation1 &__fn1, const _Operation2 &__fn2)
Definition: _function.h:285
_STLP_MOVE_TO_STD_NAMESPACE _InputIter find_if(_InputIter __first, _InputIter __last, _Predicate __pred)
Definition: _algobase.c:214
#define CPPUNIT_TEST_SUITE_END()
Definition: cppunit_mini.h:191
GLfloat param
Definition: glext.h:5796
unary_negate< _Predicate > not1(const _Predicate &__pred)
Definition: _function.h:154
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
GLenum GLenum GLenum input
Definition: glext.h:9031
void unegate3()
Definition: unary_test.cpp:63
bool test_func(int param)
Definition: unary_test.cpp:60
void ucompos1()
Definition: unary_test.cpp:73
GLuint GLenum GLenum transform
Definition: glext.h:9407
#define CPPUNIT_IGNORE
Definition: cppunit_mini.h:185
GLfloat GLfloat p
Definition: glext.h:8902
#define odd(x)
Definition: bidi.c:51
void unegate2()
Definition: unary_test.cpp:52