]> git.saurik.com Git - wxWidgets.git/blob - tests/strings/iostream.cpp
Don't ignore path when prompting for file in SaveAs()
[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 // RCS-ID: $Id$
7 // Copyright: (c) 2007 Vadim Zeitlin <vadim@wxwidgets.org>
8 ///////////////////////////////////////////////////////////////////////////////
9
10 // ----------------------------------------------------------------------------
11 // headers
12 // ----------------------------------------------------------------------------
13
14 #include "testprec.h"
15
16 #ifdef __BORLANDC__
17 #pragma hdrstop
18 #endif
19
20 #ifndef WX_PRECOMP
21 #include "wx/string.h"
22 #endif // WX_PRECOMP
23
24 #include <sstream>
25
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())
28
29 // ----------------------------------------------------------------------------
30 // test class
31 // ----------------------------------------------------------------------------
32
33 class StringIostreamTestCase : public CppUnit::TestCase
34 {
35 public:
36 StringIostreamTestCase() { }
37
38 private:
39 CPPUNIT_TEST_SUITE( StringIostreamTestCase );
40 CPPUNIT_TEST( Out );
41 CPPUNIT_TEST_SUITE_END();
42
43 void Out();
44 };
45
46 CPPUNIT_TEST_SUITE_REGISTRATION( StringIostreamTestCase );
47
48 // also include in it's own registry so that these tests can be run alone
49 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( StringIostreamTestCase, "StringIostream" );
50
51 void StringIostreamTestCase::Out()
52 {
53 std::ostringstream s;
54 s << wxString("hello");
55 ASSERT_OSTREAM_EQUAL("hello", s);
56
57 std::wostringstream ws;
58 ws << wxString("bye");
59 ASSERT_WOSTREAM_EQUAL(L"bye", ws);
60 }
61