31
|
1 |
#include <iterator>
|
|
2 |
#if !defined (STLPORT) || !defined (_STLP_USE_NO_IOSTREAMS)
|
|
3 |
#include <string>
|
|
4 |
#include <sstream>
|
|
5 |
#include <algorithm>
|
|
6 |
|
|
7 |
#include "cppunit/cppunit_proxy.h"
|
|
8 |
|
|
9 |
#if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
|
|
10 |
using namespace std;
|
|
11 |
#endif
|
|
12 |
|
|
13 |
//
|
|
14 |
// TestCase class
|
|
15 |
//
|
|
16 |
class OstreamIteratorTest : public CPPUNIT_NS::TestCase
|
|
17 |
{
|
|
18 |
CPPUNIT_TEST_SUITE(OstreamIteratorTest);
|
|
19 |
CPPUNIT_TEST(ostmit0);
|
|
20 |
CPPUNIT_TEST_SUITE_END();
|
|
21 |
|
|
22 |
protected:
|
|
23 |
void ostmit0();
|
|
24 |
};
|
|
25 |
|
|
26 |
CPPUNIT_TEST_SUITE_REGISTRATION(OstreamIteratorTest);
|
|
27 |
|
|
28 |
//
|
|
29 |
// tests implementation
|
|
30 |
//
|
|
31 |
void OstreamIteratorTest::ostmit0()
|
|
32 |
{
|
|
33 |
// not necessary, tested in copy_test
|
|
34 |
int array [] = { 1, 5, 2, 4 };
|
|
35 |
|
|
36 |
char* text = "hello";
|
|
37 |
|
|
38 |
ostringstream os;
|
|
39 |
|
|
40 |
ostream_iterator<char> iter(os);
|
|
41 |
copy(text, text + 5, iter);
|
|
42 |
CPPUNIT_ASSERT(os.good());
|
|
43 |
os << ' ';
|
|
44 |
CPPUNIT_ASSERT(os.good());
|
|
45 |
|
|
46 |
ostream_iterator<int> iter2(os);
|
|
47 |
copy(array, array + 4, iter2);
|
|
48 |
CPPUNIT_ASSERT(os.good());
|
|
49 |
CPPUNIT_ASSERT(os.str() == "hello 1524");
|
|
50 |
}
|
|
51 |
|
|
52 |
#endif
|