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 <iterator>
|
|
18 |
#if !defined (STLPORT) || !defined (_STLP_USE_NO_IOSTREAMS)
|
|
19 |
#include <string>
|
|
20 |
#include <sstream>
|
|
21 |
#include <algorithm>
|
|
22 |
|
|
23 |
#include "cppunit/cppunit_proxy.h"
|
|
24 |
|
|
25 |
#if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
|
|
26 |
using namespace std;
|
|
27 |
#endif
|
|
28 |
|
|
29 |
//
|
|
30 |
// TestCase class
|
|
31 |
//
|
|
32 |
class OstreamIteratorTest : public CPPUNIT_NS::TestCase
|
|
33 |
{
|
|
34 |
CPPUNIT_TEST_SUITE(OstreamIteratorTest);
|
|
35 |
CPPUNIT_TEST(ostmit0);
|
|
36 |
CPPUNIT_TEST_SUITE_END();
|
|
37 |
|
|
38 |
protected:
|
|
39 |
void ostmit0();
|
|
40 |
};
|
|
41 |
|
|
42 |
CPPUNIT_TEST_SUITE_REGISTRATION(OstreamIteratorTest);
|
|
43 |
|
|
44 |
//
|
|
45 |
// tests implementation
|
|
46 |
//
|
|
47 |
void OstreamIteratorTest::ostmit0()
|
|
48 |
{
|
|
49 |
// not necessary, tested in copy_test
|
|
50 |
int array [] = { 1, 5, 2, 4 };
|
|
51 |
|
|
52 |
char* text = "hello";
|
|
53 |
|
|
54 |
ostringstream os;
|
|
55 |
|
|
56 |
ostream_iterator<char> iter(os);
|
|
57 |
copy(text, text + 5, iter);
|
|
58 |
CPPUNIT_ASSERT(os.good());
|
|
59 |
os << ' ';
|
|
60 |
CPPUNIT_ASSERT(os.good());
|
|
61 |
|
|
62 |
ostream_iterator<int> iter2(os);
|
|
63 |
copy(array, array + 4, iter2);
|
|
64 |
CPPUNIT_ASSERT(os.good());
|
|
65 |
CPPUNIT_ASSERT(os.str() == "hello 1524");
|
|
66 |
}
|
|
67 |
|
|
68 |
#endif
|