Update contrib.
4 #include "cppunit/cppunit_proxy.h"
6 #if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
13 class MinTest : public CPPUNIT_NS::TestCase
15 CPPUNIT_TEST_SUITE(MinTest);
18 CPPUNIT_TEST(minelem1);
19 CPPUNIT_TEST(minelem2);
20 CPPUNIT_TEST_SUITE_END();
27 static bool str_compare(const char* a_, const char* b_)
28 { return strcmp(a_, b_) < 0 ? 1 : 0; }
31 CPPUNIT_TEST_SUITE_REGISTRATION(MinTest);
34 // tests implementation
39 CPPUNIT_ASSERT( r == 42 );
42 CPPUNIT_ASSERT( r == 41 );
46 const char* r = min((const char*)"shoe", (const char*)"shine", str_compare);
47 CPPUNIT_ASSERT(!strcmp(r, "shine"));
49 void MinTest::minelem1()
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);
55 void MinTest::minelem2()
57 const char* names[] = { "Brett", "Graham", "Jack", "Mike", "Todd" };
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"));