First public contribution.
3 #include "cppunit/cppunit_proxy.h"
5 #if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
12 class CountTest : public CPPUNIT_NS::TestCase
14 CPPUNIT_TEST_SUITE(CountTest);
17 CPPUNIT_TEST(countif1);
18 CPPUNIT_TEST_SUITE_END();
24 static int odd(int a_);
27 CPPUNIT_TEST_SUITE_REGISTRATION(CountTest);
30 // tests implementation
32 void CountTest::count0()
34 int numbers[10] = { 1, 2, 4, 1, 2, 4, 1, 2, 4, 1 };
36 int result = count(numbers, numbers + 10, 1);
37 CPPUNIT_ASSERT(result==4);
38 #if defined (STLPORT) && !defined (_STLP_NO_ANACHRONISMS)
40 count(numbers, numbers + 10, 1, result);
41 CPPUNIT_ASSERT(result==4);
44 void CountTest::count1()
46 vector <int> numbers(100);
47 for(int i = 0; i < 100; i++)
49 int elements = count(numbers.begin(), numbers.end(), 2);
50 CPPUNIT_ASSERT(elements==33);
51 #if defined (STLPORT) && !defined (_STLP_NO_ANACHRONISMS)
53 count(numbers.begin(), numbers.end(), 2, elements);
54 CPPUNIT_ASSERT(elements==33);
57 void CountTest::countif1()
59 vector <int> numbers(100);
60 for(int i = 0; i < 100; i++)
62 int elements = count_if(numbers.begin(), numbers.end(), odd);
63 CPPUNIT_ASSERT(elements==33);
64 #if defined (STLPORT) && !defined (_STLP_NO_ANACHRONISMS)
66 count_if(numbers.begin(), numbers.end(), odd, elements);
67 CPPUNIT_ASSERT(elements==33);
70 int CountTest::odd(int a_)