aboutsummaryrefslogtreecommitdiff
path: root/test/unit/pair_test.cpp
blob: 6fc5172ac0dd92de7e4067a904f6df862546d48e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <utility>
#include <vector>
#include <algorithm>
#include <string>

#include "cppunit/cppunit_proxy.h"

#if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
using namespace std;
#endif

class PairTest : public CPPUNIT_NS::TestCase
{
    CPPUNIT_TEST_SUITE(PairTest);
    CPPUNIT_TEST(pair0);
    CPPUNIT_TEST(init);
    CPPUNIT_TEST_SUITE_END();

  protected:
    void pair0();
    void init();
};

CPPUNIT_TEST_SUITE_REGISTRATION(PairTest);

void PairTest::pair0()
{
  pair<int, int> p = make_pair(1, 10);

  CPPUNIT_ASSERT(p.first==1);
  CPPUNIT_ASSERT(p.second==10);
}

void PairTest::init()
{
  pair<int, string> PAIR_ARRAY[] = { pair<int, string>(0, "0") };

  int PAIR_ARRAY_SIZE = sizeof(PAIR_ARRAY) > 0 ? sizeof(PAIR_ARRAY) / sizeof(PAIR_ARRAY[0]) : 0;


  for ( int i = 0; i < PAIR_ARRAY_SIZE; i++ ) {
    CPPUNIT_CHECK( PAIR_ARRAY[i].first == 0 );
    CPPUNIT_CHECK( PAIR_ARRAY[i].second == "0" );
    PAIR_ARRAY[i].second = "1";
  }
}