Update contrib.
4 #include "cppunit/cppunit_proxy.h"
6 #if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
13 class BoundTest : public CPPUNIT_NS::TestCase
15 CPPUNIT_TEST_SUITE(BoundTest);
16 CPPUNIT_TEST(lwrbnd1);
17 CPPUNIT_TEST(lwrbnd2);
18 CPPUNIT_TEST(uprbnd1);
19 CPPUNIT_TEST(uprbnd2);
20 CPPUNIT_TEST_SUITE_END();
28 static bool char_str_less(const char* a_, const char* b_)
30 return strcmp(a_, b_) < 0 ? 1 : 0;
34 CPPUNIT_TEST_SUITE_REGISTRATION(BoundTest);
37 // tests implementation
39 void BoundTest::uprbnd1()
42 for(int i = 0; i < 20; i++)
46 int location = upper_bound((int*)arr, (int*)arr + 20, 3) - arr;
47 CPPUNIT_ASSERT(location==16);
50 void BoundTest::uprbnd2()
52 char const* str [] = { "a", "a", "b", "b", "q", "w", "z" };
54 const unsigned strCt = sizeof(str)/sizeof(str[0]);
56 int location = (upper_bound((char const**)str, (char const**)str + strCt, (const char *)"d", char_str_less) - str);
57 CPPUNIT_ASSERT(location==4);
59 void BoundTest::lwrbnd1()
62 for (int i = 0; (size_t)i < v1.size(); ++i)
66 // 0 0 0 0 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4
67 vector<int>::iterator location = lower_bound(v1.begin(), v1.end(), 3);
69 CPPUNIT_ASSERT((location - v1.begin())==12);
72 void BoundTest::lwrbnd2()
74 char const* str [] = { "a", "a", "b", "b", "q", "w", "z" };
76 const unsigned strCt = sizeof(str)/sizeof(str[0]);
77 char const** location = lower_bound((char const**)str, (char const**)str + strCt, (const char *)"d", char_str_less);
79 CPPUNIT_ASSERT((location - str) == 4);