genericopenlibs/cppstdlib/stl/test/unit/ostmit_test.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Wed, 18 Aug 2010 11:27:44 +0300
changeset 52 bf6a71c50e42
parent 34 5fae379060a7
child 45 4b03adbd26ca
permissions -rw-r--r--
Revision: 201033 Kit: 201033
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
31
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     1
#include <iterator>
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     2
#if !defined (STLPORT) || !defined (_STLP_USE_NO_IOSTREAMS)
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     3
#include <string>
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     4
#include <sstream>
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     5
#include <algorithm>
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     6
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     7
#include "cppunit/cppunit_proxy.h"
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     8
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     9
#if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    10
using namespace std;
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    11
#endif
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    12
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    13
//
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    14
// TestCase class
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    15
//
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    16
class OstreamIteratorTest : public CPPUNIT_NS::TestCase
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    17
{
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    18
  CPPUNIT_TEST_SUITE(OstreamIteratorTest);
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    19
  CPPUNIT_TEST(ostmit0);
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    20
  CPPUNIT_TEST_SUITE_END();
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    21
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    22
protected:
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    23
  void ostmit0();
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    24
};
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    25
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    26
CPPUNIT_TEST_SUITE_REGISTRATION(OstreamIteratorTest);
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    27
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    28
//
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    29
// tests implementation
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    30
//
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    31
void OstreamIteratorTest::ostmit0()
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    32
{
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    33
  // not necessary, tested in copy_test
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    34
  int array [] = { 1, 5, 2, 4 };
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    35
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    36
  char* text = "hello";
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    37
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    38
  ostringstream os;
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    39
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    40
  ostream_iterator<char> iter(os);
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    41
  copy(text, text + 5, iter);
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    42
  CPPUNIT_ASSERT(os.good());
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    43
  os << ' ';
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    44
  CPPUNIT_ASSERT(os.good());
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    45
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    46
  ostream_iterator<int> iter2(os);
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    47
  copy(array, array + 4, iter2);
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    48
  CPPUNIT_ASSERT(os.good());
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    49
  CPPUNIT_ASSERT(os.str() == "hello 1524");
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    50
}
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    51
ce057bb09d0b Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    52
#endif