os/ossrv/genericopenlibs/cppstdlib/stl/test/unit/ostmit_test.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericopenlibs/cppstdlib/stl/test/unit/ostmit_test.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,52 @@
     1.4 +#include <iterator>
     1.5 +#if !defined (STLPORT) || !defined (_STLP_USE_NO_IOSTREAMS)
     1.6 +#include <string>
     1.7 +#include <sstream>
     1.8 +#include <algorithm>
     1.9 +
    1.10 +#include "cppunit/cppunit_proxy.h"
    1.11 +
    1.12 +#if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
    1.13 +using namespace std;
    1.14 +#endif
    1.15 +
    1.16 +//
    1.17 +// TestCase class
    1.18 +//
    1.19 +class OstreamIteratorTest : public CPPUNIT_NS::TestCase
    1.20 +{
    1.21 +  CPPUNIT_TEST_SUITE(OstreamIteratorTest);
    1.22 +  CPPUNIT_TEST(ostmit0);
    1.23 +  CPPUNIT_TEST_SUITE_END();
    1.24 +
    1.25 +protected:
    1.26 +  void ostmit0();
    1.27 +};
    1.28 +
    1.29 +CPPUNIT_TEST_SUITE_REGISTRATION(OstreamIteratorTest);
    1.30 +
    1.31 +//
    1.32 +// tests implementation
    1.33 +//
    1.34 +void OstreamIteratorTest::ostmit0()
    1.35 +{
    1.36 +  // not necessary, tested in copy_test
    1.37 +  int array [] = { 1, 5, 2, 4 };
    1.38 +
    1.39 +  char* text = "hello";
    1.40 +
    1.41 +  ostringstream os;
    1.42 +
    1.43 +  ostream_iterator<char> iter(os);
    1.44 +  copy(text, text + 5, iter);
    1.45 +  CPPUNIT_ASSERT(os.good());
    1.46 +  os << ' ';
    1.47 +  CPPUNIT_ASSERT(os.good());
    1.48 +
    1.49 +  ostream_iterator<int> iter2(os);
    1.50 +  copy(array, array + 4, iter2);
    1.51 +  CPPUNIT_ASSERT(os.good());
    1.52 +  CPPUNIT_ASSERT(os.str() == "hello 1524");
    1.53 +}
    1.54 +
    1.55 +#endif