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