ReactOS
0.4.16-dev-252-g9ccafe8
min_test.cpp
Go to the documentation of this file.
1
#include <vector>
2
#include <algorithm>
3
4
#include "
cppunit/cppunit_proxy.h
"
5
6
#if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
7
using namespace
std
;
8
#endif
9
10
//
11
// TestCase class
12
//
13
class
MinTest
:
public
CPPUNIT_NS::TestCase
14
{
15
CPPUNIT_TEST_SUITE
(
MinTest
);
16
CPPUNIT_TEST
(
min1
);
17
CPPUNIT_TEST
(
min2
);
18
CPPUNIT_TEST
(
minelem1
);
19
CPPUNIT_TEST
(
minelem2
);
20
CPPUNIT_TEST_SUITE_END
();
21
22
protected
:
23
void
min1
();
24
void
min2
();
25
void
minelem1
();
26
void
minelem2
();
27
static
bool
str_compare
(
const
char
* a_,
const
char
* b_)
28
{
return
strcmp
(a_, b_) < 0 ? 1 : 0; }
29
};
30
31
CPPUNIT_TEST_SUITE_REGISTRATION
(
MinTest
);
32
33
//
34
// tests implementation
35
//
36
void
MinTest::min1
()
37
{
38
int
r
=
min
(42, 100);
39
CPPUNIT_ASSERT
(
r
== 42 );
40
41
r
=
min
(--
r
,
r
);
42
CPPUNIT_ASSERT
(
r
== 41 );
43
}
44
void
MinTest::min2
()
45
{
46
const
char
*
r
=
min
((
const
char
*)
"shoe"
, (
const
char
*)
"shine"
,
str_compare
);
47
CPPUNIT_ASSERT
(!
strcmp
(
r
,
"shine"
));
48
}
49
void
MinTest::minelem1
()
50
{
51
int
numbers[6] = { -10, 15, -100, 36, -242, 42 };
52
int
*
r
=
min_element
((
int
*)numbers, (
int
*)numbers + 6);
53
CPPUNIT_ASSERT
(*
r
==-242);
54
}
55
void
MinTest::minelem2
()
56
{
57
const
char
*
names
[] = {
"Brett"
,
"Graham"
,
"Jack"
,
"Mike"
,
"Todd"
};
58
59
const
unsigned
namesCt =
sizeof
(
names
) /
sizeof
(
names
[0]);
60
const
char
**
r
=
min_element
((
const
char
**)
names
, (
const
char
**)
names
+ namesCt,
str_compare
);
61
CPPUNIT_ASSERT
(!
strcmp
(*
r
,
"Brett"
));
62
}
min_element
_ForwardIter min_element(_ForwardIter __first, _ForwardIter __last)
Definition:
_algo.c:1828
strcmp
int strcmp(const char *String1, const char *String2)
Definition:
utclib.c:469
MinTest
Definition:
min_test.cpp:14
MinTest::min2
void min2()
Definition:
min_test.cpp:44
MinTest::minelem1
void minelem1()
Definition:
min_test.cpp:49
MinTest::CPPUNIT_TEST_SUITE
CPPUNIT_TEST_SUITE(MinTest)
MinTest::CPPUNIT_TEST_SUITE_END
CPPUNIT_TEST_SUITE_END()
MinTest::minelem2
void minelem2()
Definition:
min_test.cpp:55
MinTest::CPPUNIT_TEST
CPPUNIT_TEST(min1)
MinTest::str_compare
static bool str_compare(const char *a_, const char *b_)
Definition:
min_test.cpp:27
MinTest::CPPUNIT_TEST
CPPUNIT_TEST(minelem2)
MinTest::CPPUNIT_TEST
CPPUNIT_TEST(min2)
MinTest::CPPUNIT_TEST
CPPUNIT_TEST(minelem1)
MinTest::min1
void min1()
Definition:
min_test.cpp:36
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
r
GLdouble GLdouble GLdouble r
Definition:
gl.h:2055
names
GLuint GLuint * names
Definition:
glext.h:11545
min
#define min(a, b)
Definition:
monoChain.cc:55
std
Definition:
features.h:417
sdk
lib
3rdparty
stlport
test
unit
min_test.cpp
Generated on Sun Nov 10 2024 06:13:13 for ReactOS by
1.9.6