]>
git.saurik.com Git - wxWidgets.git/blob - tests/strings/iostream.cpp
1 //////////////////////////////////////////////////////////////////////////////
2 // Name: tests/strings/iostream.cpp
3 // Purpose: unit test of wxString interaction with std::[io]stream
4 // Author: Vadim Zeitlin
6 // Copyright: (c) 2007 Vadim Zeitlin <vadim@wxwidgets.org>
7 ///////////////////////////////////////////////////////////////////////////////
9 // ----------------------------------------------------------------------------
11 // ----------------------------------------------------------------------------
20 #include "wx/string.h"
23 #if wxUSE_STD_IOSTREAM
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())
30 // ----------------------------------------------------------------------------
32 // ----------------------------------------------------------------------------
34 class StringIostreamTestCase
: public CppUnit::TestCase
37 StringIostreamTestCase() { }
40 CPPUNIT_TEST_SUITE( StringIostreamTestCase
);
42 CPPUNIT_TEST_SUITE_END();
47 CPPUNIT_TEST_SUITE_REGISTRATION( StringIostreamTestCase
);
49 // also include in its own registry so that these tests can be run alone
50 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( StringIostreamTestCase
, "StringIostream" );
52 void StringIostreamTestCase::Out()
55 s
<< wxString("hello");
56 ASSERT_OSTREAM_EQUAL("hello", s
);
58 #if wxUSE_UNICODE && defined(HAVE_WOSTREAM)
59 std::wostringstream ws
;
60 ws
<< wxString("bye");
61 ASSERT_WOSTREAM_EQUAL(L
"bye", ws
);
65 #endif // wxUSE_STD_IOSTREAM