]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // ------------------------------------------------------------------------------ |
2 | // format_test_wstring.cpp : test wchar_t format use (if supported) | |
3 | // ------------------------------------------------------------------------------ | |
4 | ||
5 | // Copyright Samuel Krempp 2003. Use, modification, and distribution are | |
6 | // subject to the Boost Software License, Version 1.0. (See accompanying | |
7 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
8 | ||
9 | // See http://www.boost.org/libs/format for library home page | |
10 | ||
11 | // ------------------------------------------------------------------------------ | |
12 | ||
13 | #include "boost/format.hpp" | |
14 | ||
15 | #define BOOST_INCLUDE_MAIN | |
16 | #include <boost/test/test_tools.hpp> | |
17 | ||
18 | ||
19 | int test_main(int, char* []) | |
20 | { | |
21 | ||
22 | using boost::format; | |
23 | using boost::str; | |
24 | ||
25 | #if !defined(BOOST_NO_STD_WSTRING) && !defined(BOOST_NO_STD_WSTREAMBUF) | |
26 | using boost::wformat; | |
27 | wformat wfmter(L"%%##%%##%%1 %1%00"); | |
28 | if(str( wfmter % L"Escaped OK" ) != L"%##%##%1 Escaped OK00") | |
29 | BOOST_ERROR("Basic w-parsing Failed"); | |
30 | if(str( wformat(L"%%##%#x ##%%1 %s00") % 20 % L"Escaped OK" ) != L"%##0x14 ##%1 Escaped OK00") | |
31 | BOOST_ERROR("Basic wp-parsing Failed") ; | |
7c673cae | 32 | |
b32b8144 FG |
33 | // testcase for https://svn.boost.org/trac10/ticket/7379 (for valgrind) |
34 | wformat wfmt(L"%1$.1f"); | |
35 | std::wstring ws = str(wfmt % 123.45f); | |
36 | BOOST_CHECK_EQUAL(ws.compare(L"123.4"), 0); | |
37 | wformat wfmt2(L"%1$.0f %%"); | |
38 | std::wstring ws2 = (wfmt2 % 123.45f).str(); | |
39 | BOOST_CHECK_EQUAL(ws2.compare(L"123 %"), 0); | |
40 | ||
41 | #endif // wformat tests | |
7c673cae FG |
42 | |
43 | return 0; | |
44 | } |