Home | History | Annotate | Download | only in unit
      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 FillTest : public CPPUNIT_NS::TestCase
     14 {
     15   CPPUNIT_TEST_SUITE(FillTest);
     16   CPPUNIT_TEST(fill1);
     17   CPPUNIT_TEST(filln1);
     18   CPPUNIT_TEST_SUITE_END();
     19 
     20 protected:
     21   void fill1();
     22   void filln1();
     23 };
     24 
     25 CPPUNIT_TEST_SUITE_REGISTRATION(FillTest);
     26 
     27 //
     28 // tests implementation
     29 //
     30 void FillTest::fill1()
     31 {
     32   vector <int> v(10);
     33   fill(v.begin(), v.end(), 42);
     34 
     35   CPPUNIT_ASSERT(v[0]==42);
     36   CPPUNIT_ASSERT(v[1]==42);
     37   CPPUNIT_ASSERT(v[2]==42);
     38   CPPUNIT_ASSERT(v[3]==42);
     39   CPPUNIT_ASSERT(v[4]==42);
     40   CPPUNIT_ASSERT(v[5]==42);
     41   CPPUNIT_ASSERT(v[6]==42);
     42   CPPUNIT_ASSERT(v[7]==42);
     43   CPPUNIT_ASSERT(v[8]==42);
     44   CPPUNIT_ASSERT(v[9]==42);
     45 }
     46 void FillTest::filln1()
     47 {
     48   vector <int> v(10);
     49   fill_n(v.begin(), v.size(), 42);
     50 
     51   CPPUNIT_ASSERT(v[0]==42);
     52   CPPUNIT_ASSERT(v[1]==42);
     53   CPPUNIT_ASSERT(v[2]==42);
     54   CPPUNIT_ASSERT(v[3]==42);
     55   CPPUNIT_ASSERT(v[4]==42);
     56   CPPUNIT_ASSERT(v[5]==42);
     57   CPPUNIT_ASSERT(v[6]==42);
     58   CPPUNIT_ASSERT(v[7]==42);
     59   CPPUNIT_ASSERT(v[8]==42);
     60   CPPUNIT_ASSERT(v[9]==42);
     61 }
     62