equal
deleted
inserted
replaced
|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
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 SwapTest : public CPPUNIT_NS::TestCase |
|
30 { |
|
31 CPPUNIT_TEST_SUITE(SwapTest); |
|
32 CPPUNIT_TEST(swap1); |
|
33 CPPUNIT_TEST(swprnge1); |
|
34 CPPUNIT_TEST_SUITE_END(); |
|
35 |
|
36 protected: |
|
37 void swap1(); |
|
38 void swprnge1(); |
|
39 }; |
|
40 |
|
41 CPPUNIT_TEST_SUITE_REGISTRATION(SwapTest); |
|
42 |
|
43 // |
|
44 // tests implementation |
|
45 // |
|
46 void SwapTest::swap1() |
|
47 { |
|
48 int a = 42; |
|
49 int b = 19; |
|
50 swap(a, b); |
|
51 |
|
52 CPPUNIT_ASSERT(a==19); |
|
53 CPPUNIT_ASSERT(b==42); |
|
54 } |
|
55 void SwapTest::swprnge1() |
|
56 { |
|
57 char word1[] = "World"; |
|
58 char word2[] = "Hello"; |
|
59 swap_ranges((char*)word1, (char*)word1 + ::strlen(word1), (char*)word2); |
|
60 CPPUNIT_ASSERT(!strcmp(word1, "Hello")); |
|
61 CPPUNIT_ASSERT(!strcmp(word2, "World")); |
|
62 } |