mirror of
https://github.com/boostorg/locale.git
synced 2026-01-19 04:22:08 +00:00
Simplify test by using std::put_money
This commit is contained in:
@@ -66,8 +66,7 @@ void test_by_char(const std::locale& l, const std::locale& lreal)
|
||||
const bool bad_parsing = [&]() {
|
||||
ss_ref_type ss_ref;
|
||||
ss_ref.imbue(lreal);
|
||||
ss_ref << std::showbase;
|
||||
std::use_facet<std::money_put<RefCharType>>(lreal).put(ss_ref, false, ss_ref, RefCharType(' '), 104334);
|
||||
ss_ref << std::showbase << std::put_money(104334, false);
|
||||
std::ios_base::iostate err = std::ios_base::iostate();
|
||||
typename std::money_get<RefCharType>::iter_type end;
|
||||
long double tmp;
|
||||
@@ -80,46 +79,41 @@ void test_by_char(const std::locale& l, const std::locale& lreal)
|
||||
}();
|
||||
|
||||
{
|
||||
std::cout << "- Testing as::currency national " << std::endl;
|
||||
|
||||
ss_type ss;
|
||||
ss.imbue(l);
|
||||
|
||||
TEST(ss << as::currency);
|
||||
TEST(ss << 1043.34);
|
||||
if(!bad_parsing) {
|
||||
double v1;
|
||||
if TEST(ss >> v1)
|
||||
TEST_EQ(v1, 1043.34);
|
||||
}
|
||||
|
||||
ss_ref_type ss_ref;
|
||||
ss_ref.imbue(lreal);
|
||||
ss_ref << std::showbase;
|
||||
std::use_facet<std::money_put<RefCharType>>(lreal).put(ss_ref, false, ss_ref, RefCharType(' '), 104334);
|
||||
{
|
||||
std::cout << "- Testing as::currency national " << std::endl;
|
||||
ss_type ss;
|
||||
ss.imbue(l);
|
||||
|
||||
TEST_EQ(to_utf8(ss.str()), to_utf8(ss_ref.str()));
|
||||
}
|
||||
TEST(ss << as::currency);
|
||||
TEST(ss << 1043.34);
|
||||
if(!bad_parsing) {
|
||||
double v1;
|
||||
if TEST(ss >> v1)
|
||||
TEST_EQ(v1, 1043.34);
|
||||
}
|
||||
|
||||
{
|
||||
std::cout << "- Testing as::currency iso" << std::endl;
|
||||
ss_type ss;
|
||||
ss.imbue(l);
|
||||
|
||||
ss << as::currency << as::currency_iso;
|
||||
TEST(ss << 1043.34);
|
||||
if(!bad_parsing) {
|
||||
double v1;
|
||||
if TEST(ss >> v1)
|
||||
TEST_EQ(v1, 1043.34);
|
||||
empty_stream(ss_ref) << std::put_money(104334, false);
|
||||
TEST_EQ(to_utf8(ss.str()), to_utf8(ss_ref.str()));
|
||||
}
|
||||
{
|
||||
std::cout << "- Testing as::currency iso" << std::endl;
|
||||
ss_type ss;
|
||||
ss.imbue(l);
|
||||
|
||||
ss_ref_type ss_ref;
|
||||
ss_ref.imbue(lreal);
|
||||
ss_ref << std::showbase;
|
||||
std::use_facet<std::money_put<RefCharType>>(lreal).put(ss_ref, true, ss_ref, RefCharType(' '), 104334);
|
||||
ss << as::currency << as::currency_iso;
|
||||
TEST(ss << 1043.34);
|
||||
if(!bad_parsing) {
|
||||
double v1;
|
||||
if TEST(ss >> v1)
|
||||
TEST_EQ(v1, 1043.34);
|
||||
}
|
||||
|
||||
TEST_EQ(to_utf8(ss.str()), to_utf8(ss_ref.str()));
|
||||
empty_stream(ss_ref) << std::put_money(104334, true);
|
||||
TEST_EQ(to_utf8(ss.str()), to_utf8(ss_ref.str()));
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user