]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/format/test/format_test_wstring.cpp
1 // ------------------------------------------------------------------------------
2 // format_test_wstring.cpp : test wchar_t format use (if supported)
3 // ------------------------------------------------------------------------------
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)
9 // See http://www.boost.org/libs/format for library home page
11 // ------------------------------------------------------------------------------
13 #include <boost/detail/lightweight_test.hpp>
14 #include <boost/format.hpp>
16 int main(int, char* [])
21 #if !defined(BOOST_NO_STD_WSTRING) && !defined(BOOST_NO_STD_WSTREAMBUF)
23 wformat
wfmter(L
"%%##%%##%%1 %1%00");
24 if(str( wfmter
% L
"Escaped OK" ) != L
"%##%##%1 Escaped OK00")
25 BOOST_ERROR("Basic w-parsing Failed");
26 if(str( wformat(L
"%%##%#x ##%%1 %s00") % 20 % L
"Escaped OK" ) != L
"%##0x14 ##%1 Escaped OK00")
27 BOOST_ERROR("Basic wp-parsing Failed") ;
29 // testcase for https://svn.boost.org/trac10/ticket/7379 (for valgrind)
30 wformat
wfmt(L
"%1$.1f");
31 std::wstring ws
= str(wfmt
% 123.45f
);
32 BOOST_TEST_EQ(ws
.compare(L
"123.4"), 0);
33 wformat
wfmt2(L
"%1$.0f %%");
34 std::wstring ws2
= (wfmt2
% 123.45f
).str();
35 BOOST_TEST_EQ(ws2
.compare(L
"123 %"), 0);
37 #endif // wformat tests
39 return boost::report_errors();