]> git.saurik.com Git - wxWidgets.git/blame - tests/strings/iostream.cpp
Fix install_name_tool calls in OS X "make install".
[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
99d8bc65
VZ
6// Copyright: (c) 2007 Vadim Zeitlin <vadim@wxwidgets.org>
7///////////////////////////////////////////////////////////////////////////////
8
9// ----------------------------------------------------------------------------
10// headers
11// ----------------------------------------------------------------------------
12
13#include "testprec.h"
14
15#ifdef __BORLANDC__
16 #pragma hdrstop
17#endif
18
19#ifndef WX_PRECOMP
20 #include "wx/string.h"
21#endif // WX_PRECOMP
22
fc215b41
VZ
23#if wxUSE_STD_IOSTREAM
24
99d8bc65
VZ
25#include <sstream>
26
27#define ASSERT_OSTREAM_EQUAL(p, s) CPPUNIT_ASSERT_EQUAL(std::string(p), s.str())
28#define ASSERT_WOSTREAM_EQUAL(p, s) CPPUNIT_ASSERT_EQUAL(std::wstring(p), s.str())
29
30// ----------------------------------------------------------------------------
31// test class
32// ----------------------------------------------------------------------------
33
34class StringIostreamTestCase : public CppUnit::TestCase
35{
36public:
37 StringIostreamTestCase() { }
38
39private:
40 CPPUNIT_TEST_SUITE( StringIostreamTestCase );
41 CPPUNIT_TEST( Out );
42 CPPUNIT_TEST_SUITE_END();
43
44 void Out();
45};
46
47CPPUNIT_TEST_SUITE_REGISTRATION( StringIostreamTestCase );
48
e3778b4d 49// also include in its own registry so that these tests can be run alone
99d8bc65
VZ
50CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( StringIostreamTestCase, "StringIostream" );
51
52void StringIostreamTestCase::Out()
53{
54 std::ostringstream s;
55 s << wxString("hello");
56 ASSERT_OSTREAM_EQUAL("hello", s);
57
fc215b41 58#if wxUSE_UNICODE && defined(HAVE_WOSTREAM)
99d8bc65
VZ
59 std::wostringstream ws;
60 ws << wxString("bye");
61 ASSERT_WOSTREAM_EQUAL(L"bye", ws);
6ed28b94 62#endif
99d8bc65
VZ
63}
64
fc215b41 65#endif // wxUSE_STD_IOSTREAM