ReactOS
0.4.16-dev-1521-gb8f1da6
func_test.cpp
Go to the documentation of this file.
1
#include <vector>
2
#include <algorithm>
3
#include <functional>
4
5
#include "
cppunit/cppunit_proxy.h
"
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
{
16
CPPUNIT_TEST_SUITE
(
FuncTest
);
17
CPPUNIT_TEST
(
func1
);
18
CPPUNIT_TEST
(
func2
);
19
CPPUNIT_TEST
(
func3
);
20
CPPUNIT_TEST_SUITE_END
();
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
30
CPPUNIT_TEST_SUITE_REGISTRATION
(
FuncTest
);
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
}
43
void
FuncTest::func1
()
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
53
void
FuncTest::func2
()
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
}
65
void
FuncTest::func3
()
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
}
count_if
_STLP_INLINE_LOOP void count_if(_InputIter __first, _InputIter __last, _Predicate __pred, _Size &__n)
Definition:
_algo.h:115
FuncTest
Definition:
func_test.cpp:15
FuncTest::func2
void func2()
Definition:
func_test.cpp:53
FuncTest::bigger
static bool bigger(int i_)
Definition:
func_test.cpp:35
FuncTest::CPPUNIT_TEST
CPPUNIT_TEST(func2)
FuncTest::func1
void func1()
Definition:
func_test.cpp:43
FuncTest::CPPUNIT_TEST_SUITE
CPPUNIT_TEST_SUITE(FuncTest)
FuncTest::bigger_than
static bool bigger_than(int x_, int y_)
Definition:
func_test.cpp:39
FuncTest::func3
void func3()
Definition:
func_test.cpp:65
FuncTest::CPPUNIT_TEST
CPPUNIT_TEST(func1)
FuncTest::CPPUNIT_TEST_SUITE_END
CPPUNIT_TEST_SUITE_END()
FuncTest::CPPUNIT_TEST
CPPUNIT_TEST(func3)
CPPUNIT_TEST_SUITE_REGISTRATION
#define CPPUNIT_TEST_SUITE_REGISTRATION(X)
Definition:
cppunit_mini.h:193
CPPUNIT_ASSERT
#define CPPUNIT_ASSERT(X)
Definition:
cppunit_mini.h:200
cppunit_proxy.h
sort
static struct @513 sort
v
const GLdouble * v
Definition:
gl.h:2040
n
GLdouble n
Definition:
glext.h:7729
std
Definition:
features.h:417
greater
Definition:
_function.h:49
sdk
lib
3rdparty
stlport
test
unit
func_test.cpp
Generated on Wed Jul 16 2025 06:14:23 for ReactOS by
1.9.6