Home | History | Annotate | Download | only in unit
      1 #include <utility>
      2 #include <vector>
      3 #include <algorithm>
      4 #include <string>
      5 
      6 #include "cppunit/cppunit_proxy.h"
      7 
      8 #if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
      9 using namespace std;
     10 #endif
     11 
     12 class PairTest : public CPPUNIT_NS::TestCase
     13 {
     14     CPPUNIT_TEST_SUITE(PairTest);
     15     CPPUNIT_TEST(pair0);
     16     CPPUNIT_TEST(init);
     17     CPPUNIT_TEST_SUITE_END();
     18 
     19   protected:
     20     void pair0();
     21     void init();
     22 };
     23 
     24 CPPUNIT_TEST_SUITE_REGISTRATION(PairTest);
     25 
     26 void PairTest::pair0()
     27 {
     28   pair<int, int> p = make_pair(1, 10);
     29 
     30   CPPUNIT_ASSERT(p.first==1);
     31   CPPUNIT_ASSERT(p.second==10);
     32 }
     33 
     34 void PairTest::init()
     35 {
     36   pair<int, string> PAIR_ARRAY[] = { pair<int, string>(0, "0") };
     37 
     38   int PAIR_ARRAY_SIZE = sizeof(PAIR_ARRAY) > 0 ? sizeof(PAIR_ARRAY) / sizeof(PAIR_ARRAY[0]) : 0;
     39 
     40 
     41   for ( int i = 0; i < PAIR_ARRAY_SIZE; i++ ) {
     42     CPPUNIT_CHECK( PAIR_ARRAY[i].first == 0 );
     43     CPPUNIT_CHECK( PAIR_ARRAY[i].second == "0" );
     44     PAIR_ARRAY[i].second = "1";
     45   }
     46 }
     47