ReactOS 0.4.15-dev-8135-g1bc6c90
min_test.cpp
Go to the documentation of this file.
1#include <vector>
2#include <algorithm>
3
5
6#if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
7using namespace std;
8#endif
9
10//
11// TestCase class
12//
13class MinTest : public CPPUNIT_NS::TestCase
14{
21
22protected:
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
32
33//
34// tests implementation
35//
37{
38 int r = min(42, 100);
39 CPPUNIT_ASSERT( r == 42 );
40
41 r = min(--r, r);
42 CPPUNIT_ASSERT( r == 41 );
43}
45{
46 const char* r = min((const char*)"shoe", (const char*)"shine", str_compare);
47 CPPUNIT_ASSERT(!strcmp(r, "shine"));
48}
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}
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}
_ForwardIter min_element(_ForwardIter __first, _ForwardIter __last)
Definition: _algo.c:1828
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
void min2()
Definition: min_test.cpp:44
void minelem1()
Definition: min_test.cpp:49
CPPUNIT_TEST_SUITE(MinTest)
CPPUNIT_TEST_SUITE_END()
void minelem2()
Definition: min_test.cpp:55
CPPUNIT_TEST(min1)
static bool str_compare(const char *a_, const char *b_)
Definition: min_test.cpp:27
CPPUNIT_TEST(minelem2)
CPPUNIT_TEST(min2)
CPPUNIT_TEST(minelem1)
void min1()
Definition: min_test.cpp:36
#define CPPUNIT_TEST_SUITE_REGISTRATION(X)
Definition: cppunit_mini.h:193
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLuint GLuint * names
Definition: glext.h:11545
#define min(a, b)
Definition: monoChain.cc:55
Definition: features.h:417