]>
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
7 // Copyright: (c) 2007 Vadim Zeitlin <vadim@wxwidgets.org>
8 ///////////////////////////////////////////////////////////////////////////////
10 // ----------------------------------------------------------------------------
12 // ----------------------------------------------------------------------------
21 #include "wx/string.h"
24 #if wxUSE_STD_IOSTREAM
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())
31 // ----------------------------------------------------------------------------
33 // ----------------------------------------------------------------------------
35 class StringIostreamTestCase
: public CppUnit::TestCase
38 StringIostreamTestCase() { }
41 CPPUNIT_TEST_SUITE( StringIostreamTestCase
);
43 CPPUNIT_TEST_SUITE_END();
48 CPPUNIT_TEST_SUITE_REGISTRATION( StringIostreamTestCase
);
50 // also include in its own registry so that these tests can be run alone
51 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( StringIostreamTestCase
, "StringIostream" );
53 void StringIostreamTestCase::Out()
56 s
<< wxString("hello");
57 ASSERT_OSTREAM_EQUAL("hello", s
);
59 #if wxUSE_UNICODE && defined(HAVE_WOSTREAM)
60 std::wostringstream ws
;
61 ws
<< wxString("bye");
62 ASSERT_WOSTREAM_EQUAL(L
"bye", ws
);
66 #endif // wxUSE_STD_IOSTREAM