From a092e4ebbabead18ccd04822c7c06e9dbc6cd77c Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Thu, 7 Feb 2002 20:27:38 +0100 Subject: [PATCH] money_get_members_char.cc: Add comment, tidy up. 2002-02-07 Paolo Carlini * testsuite/22_locale/money_get_members_char.cc: Add comment, tidy up. (test01): more "en_HK" tests (without showbase). * testsuite/22_locale/money_get_members_wchar_t.cc: Ditto. From-SVN: r49587 --- libstdc++-v3/ChangeLog | 7 +++ .../22_locale/money_get_members_char.cc | 48 ++++++++++++++----- .../22_locale/money_get_members_wchar_t.cc | 48 ++++++++++++++----- 3 files changed, 79 insertions(+), 24 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index fdc204f9da8..f384f07fa76 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,10 @@ +2002-02-07 Paolo Carlini + + * testsuite/22_locale/money_get_members_char.cc: + Add comment, tidy up. + (test01): more "en_HK" tests (without showbase). + * testsuite/22_locale/money_get_members_wchar_t.cc: Ditto. + 2002-02-06 Loren Rittle * config/locale/c_locale_generic.cc: Do not trust diff --git a/libstdc++-v3/testsuite/22_locale/money_get_members_char.cc b/libstdc++-v3/testsuite/22_locale/money_get_members_char.cc index 148854a33d1..e26189c32c3 100644 --- a/libstdc++-v3/testsuite/22_locale/money_get_members_char.cc +++ b/libstdc++-v3/testsuite/22_locale/money_get_members_char.cc @@ -170,6 +170,36 @@ void test01() mon_get.get(is_it11, end, true, iss, err11, result11); VERIFY( result11 == digits4 ); VERIFY( err11 == ios_base::goodbit ); + + // for the "en_HK" locale the parsing of the very same input streams must + // be successful without showbase too, since the symbol field appears in + // the first positions in the format and the symbol, when present, must be + // consumed. + iss.unsetf(ios_base::showbase); + + iss.str("HK$7,200,000,000.00"); + iterator_type is_it12(iss); + string result12; + ios_base::iostate err12 = ios_base::goodbit; + mon_get.get(is_it12, end, false, iss, err12, result12); + VERIFY( result12 == digits1 ); + VERIFY( err12 == ios_base::eofbit ); + + iss.str("(HKD 100,000,000,000.00)"); + iterator_type is_it13(iss); + string result13; + ios_base::iostate err13 = ios_base::goodbit; + mon_get.get(is_it13, end, true, iss, err13, result13); + VERIFY( result13 == digits2 ); + VERIFY( err13 == ios_base::goodbit ); + + iss.str("(HKD .01)"); + iterator_type is_it14(iss); + string result14; + ios_base::iostate err14 = ios_base::goodbit; + mon_get.get(is_it14, end, true, iss, err14, result14); + VERIFY( result14 == digits4 ); + VERIFY( err14 == ios_base::goodbit ); } // test double version @@ -309,12 +339,9 @@ void test04() #endif } -class My_money_io : public std::moneypunct +struct My_money_io : public std::moneypunct { -public: - explicit My_money_io(size_t r = 0): std::moneypunct(r) { } char_type do_decimal_point() const { return '.'; } - char_type do_thousands_sep() const { return ','; } std::string do_grouping() const { return "\004"; } std::string do_curr_symbol() const { return "$"; } @@ -383,6 +410,9 @@ void test05() VERIFY( valn_ns == "-123456" ); } +// We were appending to the string val passed by reference, instead +// of constructing a temporary candidate, eventually copied into +// val in case of successful parsing. void test06() { using namespace std; @@ -419,12 +449,9 @@ void test06() VERIFY( val == buffer3 ); } -class My_money_io_a : public std::moneypunct +struct My_money_io_a : public std::moneypunct { -public: - explicit My_money_io_a(size_t r = 0): std::moneypunct(r) { } char_type do_decimal_point() const { return '.'; } - char_type do_thousands_sep() const { return ','; } std::string do_grouping() const { return "\004"; } std::string do_curr_symbol() const { return "$"; } @@ -439,12 +466,9 @@ public: } }; -class My_money_io_b : public std::moneypunct +struct My_money_io_b : public std::moneypunct { -public: - explicit My_money_io_b(size_t r = 0): std::moneypunct(r) { } char_type do_decimal_point() const { return '.'; } - char_type do_thousands_sep() const { return ','; } std::string do_grouping() const { return "\004"; } std::string do_curr_symbol() const { return "$"; } diff --git a/libstdc++-v3/testsuite/22_locale/money_get_members_wchar_t.cc b/libstdc++-v3/testsuite/22_locale/money_get_members_wchar_t.cc index cf9ff1fca4b..9f79661a080 100644 --- a/libstdc++-v3/testsuite/22_locale/money_get_members_wchar_t.cc +++ b/libstdc++-v3/testsuite/22_locale/money_get_members_wchar_t.cc @@ -171,6 +171,36 @@ void test01() mon_get.get(is_it11, end, true, iss, err11, result11); VERIFY( result11 == digits4 ); VERIFY( err11 == ios_base::goodbit ); + + // for the "en_HK" locale the parsing of the very same input streams must + // be successful without showbase too, since the symbol field appears in + // the first positions in the format and the symbol, when present, must be + // consumed. + iss.unsetf(ios_base::showbase); + + iss.str(L"HK$7,200,000,000.00"); + iterator_type is_it12(iss); + wstring result12; + ios_base::iostate err12 = ios_base::goodbit; + mon_get.get(is_it12, end, false, iss, err12, result12); + VERIFY( result12 == digits1 ); + VERIFY( err12 == ios_base::eofbit ); + + iss.str(L"(HKD 100,000,000,000.00)"); + iterator_type is_it13(iss); + wstring result13; + ios_base::iostate err13 = ios_base::goodbit; + mon_get.get(is_it13, end, true, iss, err13, result13); + VERIFY( result13 == digits2 ); + VERIFY( err13 == ios_base::goodbit ); + + iss.str(L"(HKD .01)"); + iterator_type is_it14(iss); + wstring result14; + ios_base::iostate err14 = ios_base::goodbit; + mon_get.get(is_it14, end, true, iss, err14, result14); + VERIFY( result14 == digits4 ); + VERIFY( err14 == ios_base::goodbit ); } @@ -311,12 +341,9 @@ void test04() #endif } -class My_money_io : public std::moneypunct +struct My_money_io : public std::moneypunct { -public: - explicit My_money_io(size_t r = 0): std::moneypunct(r) { } char_type do_decimal_point() const { return L'.'; } - char_type do_thousands_sep() const { return L','; } std::string do_grouping() const { return "\004"; } std::wstring do_curr_symbol() const { return L"$"; } @@ -385,6 +412,9 @@ void test05() VERIFY( valn_ns == L"-123456" ); } +// We were appending to the string val passed by reference, instead +// of constructing a temporary candidate, eventually copied into +// val in case of successful parsing. void test06() { using namespace std; @@ -421,12 +451,9 @@ void test06() VERIFY( val == buffer3 ); } -class My_money_io_a : public std::moneypunct +struct My_money_io_a : public std::moneypunct { -public: - explicit My_money_io_a(size_t r = 0): std::moneypunct(r) { } char_type do_decimal_point() const { return L'.'; } - char_type do_thousands_sep() const { return L','; } std::string do_grouping() const { return "\004"; } std::wstring do_curr_symbol() const { return L"$"; } @@ -441,12 +468,9 @@ public: } }; -class My_money_io_b : public std::moneypunct +struct My_money_io_b : public std::moneypunct { -public: - explicit My_money_io_b(size_t r = 0): std::moneypunct(r) { } char_type do_decimal_point() const { return L'.'; } - char_type do_thousands_sep() const { return L','; } std::string do_grouping() const { return "\004"; } std::wstring do_curr_symbol() const { return L"$"; } -- 2.30.2