|
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <utility> |
|
17 #include <vector> |
|
18 #include <algorithm> |
|
19 |
|
20 #include "cppunit/cppunit_proxy.h" |
|
21 |
|
22 #if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES) |
|
23 using namespace std; |
|
24 #endif |
|
25 |
|
26 // |
|
27 // TestCase class |
|
28 // |
|
29 class PairTest : public CPPUNIT_NS::TestCase |
|
30 { |
|
31 CPPUNIT_TEST_SUITE(PairTest); |
|
32 CPPUNIT_TEST(pair0); |
|
33 CPPUNIT_TEST(pair_cov); |
|
34 CPPUNIT_TEST_SUITE_END(); |
|
35 |
|
36 protected: |
|
37 void pair0(); |
|
38 void pair_cov(); |
|
39 }; |
|
40 |
|
41 CPPUNIT_TEST_SUITE_REGISTRATION(PairTest); |
|
42 |
|
43 // |
|
44 // tests implementation |
|
45 // |
|
46 void PairTest::pair0() |
|
47 { |
|
48 pair<int, int> p = make_pair(1, 10); |
|
49 |
|
50 CPPUNIT_ASSERT(p.first==1); |
|
51 CPPUNIT_ASSERT(p.second==10); |
|
52 } |
|
53 void PairTest::pair_cov() |
|
54 { |
|
55 pair<int, int> p1 = make_pair(1, 10); |
|
56 pair<int, int> p2 = make_pair(2, 10); |
|
57 bool val; |
|
58 |
|
59 val = (p1 >= p2); |
|
60 CPPUNIT_ASSERT(val == false); |
|
61 val = (p1 > p2); |
|
62 CPPUNIT_ASSERT(val == false); |
|
63 val = (p1 <= p2); |
|
64 CPPUNIT_ASSERT(val == true); |
|
65 val = (p1 < p2); |
|
66 CPPUNIT_ASSERT(val == true); |
|
67 val = (p1 != p2); |
|
68 CPPUNIT_ASSERT(val == true); |
|
69 val = (p1 == p2); |
|
70 CPPUNIT_ASSERT(val == false); |
|
71 } |