]> git.saurik.com Git - wxWidgets.git/blob - tests/strings/iostream.cpp
Basque translations update from Xabier Aramendi.
[wxWidgets.git] / 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
5 // Created: 2007-10-09
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
23 #if wxUSE_STD_IOSTREAM
24
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
34 class StringIostreamTestCase : public CppUnit::TestCase
35 {
36 public:
37 StringIostreamTestCase() { }
38
39 private:
40 CPPUNIT_TEST_SUITE( StringIostreamTestCase );
41 CPPUNIT_TEST( Out );
42 CPPUNIT_TEST_SUITE_END();
43
44 void Out();
45 };
46
47 CPPUNIT_TEST_SUITE_REGISTRATION( StringIostreamTestCase );
48
49 // also include in its own registry so that these tests can be run alone
50 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( StringIostreamTestCase, "StringIostream" );
51
52 void StringIostreamTestCase::Out()
53 {
54 std::ostringstream s;
55 s << wxString("hello");
56 ASSERT_OSTREAM_EQUAL("hello", s);
57
58 #if wxUSE_UNICODE && defined(HAVE_WOSTREAM)
59 std::wostringstream ws;
60 ws << wxString("bye");
61 ASSERT_WOSTREAM_EQUAL(L"bye", ws);
62 #endif
63 }
64
65 #endif // wxUSE_STD_IOSTREAM