|
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 #include <deque> |
|
20 |
|
21 #include "cppunit/cppunit_proxy.h" |
|
22 |
|
23 #if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES) |
|
24 using namespace std; |
|
25 #endif |
|
26 |
|
27 // |
|
28 // TestCase class |
|
29 // |
|
30 class FinsertTest : public CPPUNIT_NS::TestCase |
|
31 { |
|
32 CPPUNIT_TEST_SUITE(FinsertTest); |
|
33 CPPUNIT_TEST(finsert1); |
|
34 CPPUNIT_TEST(finsert2); |
|
35 CPPUNIT_TEST_SUITE_END(); |
|
36 |
|
37 protected: |
|
38 void finsert1(); |
|
39 void finsert2(); |
|
40 }; |
|
41 |
|
42 CPPUNIT_TEST_SUITE_REGISTRATION(FinsertTest); |
|
43 |
|
44 // |
|
45 // tests implementation |
|
46 // |
|
47 void FinsertTest::finsert1() |
|
48 { |
|
49 char const* array [] = { "laurie", "jennifer", "leisa" }; |
|
50 deque<char const*> names; |
|
51 front_insert_iterator<deque<char const*> > fit(names); |
|
52 fit = copy(array, array + 3, front_insert_iterator<deque <char const*> >(names)); |
|
53 |
|
54 CPPUNIT_ASSERT(names[0]==array[2]); |
|
55 CPPUNIT_ASSERT(names[1]==array[1]); |
|
56 CPPUNIT_ASSERT(names[2]==array[0]); |
|
57 |
|
58 copy(array, array + 3, fit); |
|
59 CPPUNIT_ASSERT(names[3]==array[2]); |
|
60 CPPUNIT_ASSERT(names[4]==array[1]); |
|
61 CPPUNIT_ASSERT(names[5]==array[0]); |
|
62 } |
|
63 |
|
64 void FinsertTest::finsert2() |
|
65 { |
|
66 char const* array [] = { "laurie", "jennifer", "leisa" }; |
|
67 |
|
68 deque<char const*> names; |
|
69 copy(array, array + 3, front_inserter(names)); |
|
70 |
|
71 CPPUNIT_ASSERT(names[0]==array[2]); |
|
72 CPPUNIT_ASSERT(names[1]==array[1]); |
|
73 CPPUNIT_ASSERT(names[2]==array[0]); |
|
74 } |