• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/detail/lightweight_test.hpp>
14  #include <boost/format.hpp>
15  
main(int,char * [])16  int main(int, char* [])
17  {
18    using boost::format;
19    using boost::str;
20  
21  #if !defined(BOOST_NO_STD_WSTRING) && !defined(BOOST_NO_STD_WSTREAMBUF)
22    using boost::wformat;
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") ;
28  
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);
36  
37  #endif // wformat tests
38  
39    return boost::report_errors();
40  }
41