]>
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"
26 #define ASSERT_OSTREAM_EQUAL(p, s) CPPUNIT_ASSERT_EQUAL(std::string(p), s.str())
27 #define ASSERT_WOSTREAM_EQUAL(p, s) CPPUNIT_ASSERT_EQUAL(std::wstring(p), s.str())
29 // ----------------------------------------------------------------------------
31 // ----------------------------------------------------------------------------
33 class StringIostreamTestCase
: public CppUnit::TestCase
36 StringIostreamTestCase() { }
39 CPPUNIT_TEST_SUITE( StringIostreamTestCase
);
41 CPPUNIT_TEST_SUITE_END();
46 CPPUNIT_TEST_SUITE_REGISTRATION( StringIostreamTestCase
);
48 // also include in it's own registry so that these tests can be run alone
49 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( StringIostreamTestCase
, "StringIostream" );
51 void StringIostreamTestCase::Out()
54 s
<< wxString("hello");
55 ASSERT_OSTREAM_EQUAL("hello", s
);
58 std::wostringstream ws
;
59 ws
<< wxString("bye");
60 ASSERT_WOSTREAM_EQUAL(L
"bye", ws
);