]> git.saurik.com Git - wxWidgets.git/blame - tests/strings/iostream.cpp
Make wxMBConv_iconv MT-safe by not using wxString in it.
[wxWidgets.git] / tests / strings / iostream.cpp
CommitLineData
99d8bc65
VZ
1//////////////////////////////////////////////////////////////////////////////
2// Name: tests/strings/iostream.cpp
3// Purpose: unit test of wxString interaction with std::[io]stream
4// Author: Vadim Zeitlin
5// Created: 2007-10-09
6// RCS-ID: $Id$
7// Copyright: (c) 2007 Vadim Zeitlin <vadim@wxwidgets.org>
8///////////////////////////////////////////////////////////////////////////////
9
10// ----------------------------------------------------------------------------
11// headers
12// ----------------------------------------------------------------------------
13
14#include "testprec.h"
15
16#ifdef __BORLANDC__
17 #pragma hdrstop
18#endif
19
20#ifndef WX_PRECOMP
21 #include "wx/string.h"
22#endif // WX_PRECOMP
23
fc215b41
VZ
24#if wxUSE_STD_IOSTREAM
25
99d8bc65
VZ
26#include <sstream>
27
28#define ASSERT_OSTREAM_EQUAL(p, s) CPPUNIT_ASSERT_EQUAL(std::string(p), s.str())
29#define ASSERT_WOSTREAM_EQUAL(p, s) CPPUNIT_ASSERT_EQUAL(std::wstring(p), s.str())
30
31// ----------------------------------------------------------------------------
32// test class
33// ----------------------------------------------------------------------------
34
35class StringIostreamTestCase : public CppUnit::TestCase
36{
37public:
38 StringIostreamTestCase() { }
39
40private:
41 CPPUNIT_TEST_SUITE( StringIostreamTestCase );
42 CPPUNIT_TEST( Out );
43 CPPUNIT_TEST_SUITE_END();
44
45 void Out();
46};
47
48CPPUNIT_TEST_SUITE_REGISTRATION( StringIostreamTestCase );
49
50// also include in it's own registry so that these tests can be run alone
51CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( StringIostreamTestCase, "StringIostream" );
52
53void StringIostreamTestCase::Out()
54{
55 std::ostringstream s;
56 s << wxString("hello");
57 ASSERT_OSTREAM_EQUAL("hello", s);
58
fc215b41 59#if wxUSE_UNICODE && defined(HAVE_WOSTREAM)
99d8bc65
VZ
60 std::wostringstream ws;
61 ws << wxString("bye");
62 ASSERT_WOSTREAM_EQUAL(L"bye", ws);
6ed28b94 63#endif
99d8bc65
VZ
64}
65
fc215b41 66#endif // wxUSE_STD_IOSTREAM