ReactOS 0.4.16-dev-340-g0540c21
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)
8using namespace std;
9#endif
10
11//
12// TestCase class
13//
14class FuncTest : public CPPUNIT_NS::TestCase
15{
21
22protected:
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//
35bool FuncTest::bigger(int i_)
36{
37 return i_ > 3;
38}
39bool 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}
_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
void func2()
Definition: func_test.cpp:53
static bool bigger(int i_)
Definition: func_test.cpp:35
CPPUNIT_TEST(func2)
void func1()
Definition: func_test.cpp:43
CPPUNIT_TEST_SUITE(FuncTest)
static bool bigger_than(int x_, int y_)
Definition: func_test.cpp:39
void func3()
Definition: func_test.cpp:65
CPPUNIT_TEST(func1)
CPPUNIT_TEST_SUITE_END()
CPPUNIT_TEST(func3)
#define CPPUNIT_TEST_SUITE_REGISTRATION(X)
Definition: cppunit_mini.h:193
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
const GLdouble * v
Definition: gl.h:2040
GLdouble n
Definition: glext.h:7729
Definition: features.h:417