ReactOS  0.4.13-dev-100-gc8611ae
func_test.cpp
Go to the documentation of this file.
1 #include <vector>
2 #include <algorithm>
3 #include <functional>
4 
6 
7 #if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
8 using namespace std;
9 #endif
10 
11 //
12 // TestCase class
13 //
14 class FuncTest : public CPPUNIT_NS::TestCase
15 {
17  CPPUNIT_TEST(func1);
18  CPPUNIT_TEST(func2);
19  CPPUNIT_TEST(func3);
21 
22 protected:
23  void func1();
24  void func2();
25  void func3();
26  static bool bigger(int i_);
27  static bool bigger_than(int x_, int y_);
28 };
29 
31 
32 //
33 // tests implementation
34 //
35 bool FuncTest::bigger(int i_)
36 {
37  return i_ > 3;
38 }
39 bool FuncTest::bigger_than(int x_, int y_)
40 {
41  return x_ > y_;
42 }
44 {
45  vector<int>v;
46  v.push_back(4);
47  v.push_back(1);
48  v.push_back(5);
49  int n = count_if(v.begin(), v.end(), bigger);
50  CPPUNIT_ASSERT( n == 2 )
51 }
52 
54 {
55  vector<int> v;
56  v.push_back(4);
57  v.push_back(1);
58  v.push_back(5);
59  sort(v.begin(), v.end(), bigger_than);
60 
61  CPPUNIT_ASSERT( v[0] == 5 );
62  CPPUNIT_ASSERT( v[1] == 4 );
63  CPPUNIT_ASSERT( v[2] == 1 );
64 }
66 {
67  vector<int> v;
68  v.push_back(4);
69  v.push_back(1);
70  v.push_back(5);
71  sort(v.begin(), v.end(), greater<int>());
72 
73  CPPUNIT_ASSERT( v[0] == 5 );
74  CPPUNIT_ASSERT( v[1] == 4 );
75  CPPUNIT_ASSERT( v[2] == 1 );
76 }
CPPUNIT_TEST_SUITE_REGISTRATION(FuncTest)
static bool bigger(int i_)
Definition: func_test.cpp:35
static bool bigger_than(int x_, int y_)
Definition: func_test.cpp:39
_STLP_MOVE_TO_STD_NAMESPACE void sort(_RandomAccessIter __first, _RandomAccessIter __last)
Definition: _algo.c:993
_STLP_INLINE_LOOP void count_if(_InputIter __first, _InputIter __last, _Predicate __pred, _Size &__n)
Definition: _algo.h:115
GLdouble n
Definition: glext.h:7729
#define CPPUNIT_TEST_SUITE(X)
Definition: cppunit_mini.h:142
#define CPPUNIT_TEST(X)
Definition: cppunit_mini.h:182
Definition: features.h:417
void func1()
Definition: func_test.cpp:43
#define CPPUNIT_TEST_SUITE_END()
Definition: cppunit_mini.h:191
void func3()
Definition: func_test.cpp:65
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
const GLdouble * v
Definition: gl.h:2040
void func2()
Definition: func_test.cpp:53