/usr/lib/Wt/test/locale/LocaleNumberTest.C is in witty-examples 3.3.0-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | /*
* Copyright (C) 2011 Emweb bvba, Kessel-Lo, Belgium.
*
* See the LICENSE file for terms of use.
*/
#include <boost/test/unit_test.hpp>
#include <boost/lexical_cast.hpp>
#include <Wt/WLocale>
using namespace Wt;
BOOST_AUTO_TEST_CASE( formatCLocale )
{
double d = 12345678.2345;
WLocale l;
WString s = l.toString(d);
BOOST_REQUIRE(s == "12345678.2345");
}
BOOST_AUTO_TEST_CASE( formatGrouping )
{
double d = 12345678.2345;
WLocale l;
l.setGroupSeparator(",");
WString s = l.toString(d);
BOOST_REQUIRE(s == "12,345,678.2345");
s = l.toString(d / 10);
BOOST_REQUIRE(s == "1,234,567.82345");
BOOST_REQUIRE((l.toDouble(s) - d / 10) < 1E-6);
s = l.toString(d / 100);
BOOST_REQUIRE(s == "123,456.782345");
BOOST_REQUIRE((l.toDouble(s) - d / 100) < 1E-7);
s = l.toString(d / 1E30);
BOOST_REQUIRE(s == boost::lexical_cast<std::string>(d / 1E30));
s = l.toString(d * 1E30);
#ifdef WIN32
BOOST_REQUIRE(s == "1.23456782345e+037");
#else
BOOST_REQUIRE(s == "1.23456782345e+37");
#endif
s = l.toString(d / -1E30);
BOOST_REQUIRE(s == boost::lexical_cast<std::string>(d / -1E30));
s = l.toString(d * -1E30);
#ifdef WIN32
BOOST_REQUIRE(s == "-1.23456782345e+037");
#else
BOOST_REQUIRE(s == "-1.23456782345e+37");
#endif
}
|