31
|
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 BinsertTest : public CPPUNIT_NS::TestCase
|
|
30 |
{
|
|
31 |
CPPUNIT_TEST_SUITE(BinsertTest);
|
|
32 |
CPPUNIT_TEST(binsert1);
|
|
33 |
CPPUNIT_TEST(binsert2);
|
|
34 |
CPPUNIT_TEST_SUITE_END();
|
|
35 |
|
|
36 |
protected:
|
|
37 |
void binsert1();
|
|
38 |
void binsert2();
|
|
39 |
};
|
|
40 |
|
|
41 |
CPPUNIT_TEST_SUITE_REGISTRATION(BinsertTest);
|
|
42 |
|
|
43 |
//
|
|
44 |
// tests implementation
|
|
45 |
//
|
|
46 |
void BinsertTest::binsert1()
|
|
47 |
{
|
|
48 |
char* array [] = { "laurie", "jennifer", "leisa" };
|
|
49 |
vector<char*> names;
|
|
50 |
back_insert_iterator<vector<char*> > bit(names);
|
|
51 |
bit = copy(array, array + 3, back_insert_iterator<vector <char*> >(names));
|
|
52 |
|
|
53 |
CPPUNIT_ASSERT(!strcmp(names[0],array[0]));
|
|
54 |
CPPUNIT_ASSERT(!strcmp(names[1],array[1]));
|
|
55 |
CPPUNIT_ASSERT(!strcmp(names[2],array[2]));
|
|
56 |
|
|
57 |
copy(array, array + 3, bit);
|
|
58 |
CPPUNIT_ASSERT(!strcmp(names[3],array[0]));
|
|
59 |
CPPUNIT_ASSERT(!strcmp(names[4],array[1]));
|
|
60 |
CPPUNIT_ASSERT(!strcmp(names[5],array[2]));
|
|
61 |
}
|
|
62 |
void BinsertTest::binsert2()
|
|
63 |
{
|
|
64 |
char* array [] = { "laurie", "jennifer", "leisa" };
|
|
65 |
vector<char*> names;
|
|
66 |
copy(array, array + 3, back_inserter(names));
|
|
67 |
CPPUNIT_ASSERT(!strcmp(names[0],array[0]));
|
|
68 |
CPPUNIT_ASSERT(!strcmp(names[1],array[1]));
|
|
69 |
CPPUNIT_ASSERT(!strcmp(names[2],array[2]));
|
|
70 |
}
|