Commit a092e4eb by Paolo Carlini Committed by Paolo Carlini

money_get_members_char.cc: Add comment, tidy up.

2002-02-07  Paolo Carlini  <pcarlini@unitus.it>

	* 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
parent 85ea93b3
2002-02-07 Paolo Carlini <pcarlini@unitus.it>
* 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 <ljrittle@acm.org> 2002-02-06 Loren Rittle <ljrittle@acm.org>
* config/locale/c_locale_generic.cc: Do not trust * config/locale/c_locale_generic.cc: Do not trust
......
...@@ -170,6 +170,36 @@ void test01() ...@@ -170,6 +170,36 @@ void test01()
mon_get.get(is_it11, end, true, iss, err11, result11); mon_get.get(is_it11, end, true, iss, err11, result11);
VERIFY( result11 == digits4 ); VERIFY( result11 == digits4 );
VERIFY( err11 == ios_base::goodbit ); 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 // test double version
...@@ -309,12 +339,9 @@ void test04() ...@@ -309,12 +339,9 @@ void test04()
#endif #endif
} }
class My_money_io : public std::moneypunct<char,false> struct My_money_io : public std::moneypunct<char,false>
{ {
public:
explicit My_money_io(size_t r = 0): std::moneypunct<char,false>(r) { }
char_type do_decimal_point() const { return '.'; } char_type do_decimal_point() const { return '.'; }
char_type do_thousands_sep() const { return ','; }
std::string do_grouping() const { return "\004"; } std::string do_grouping() const { return "\004"; }
std::string do_curr_symbol() const { return "$"; } std::string do_curr_symbol() const { return "$"; }
...@@ -383,6 +410,9 @@ void test05() ...@@ -383,6 +410,9 @@ void test05()
VERIFY( valn_ns == "-123456" ); 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() void test06()
{ {
using namespace std; using namespace std;
...@@ -419,12 +449,9 @@ void test06() ...@@ -419,12 +449,9 @@ void test06()
VERIFY( val == buffer3 ); VERIFY( val == buffer3 );
} }
class My_money_io_a : public std::moneypunct<char,false> struct My_money_io_a : public std::moneypunct<char,false>
{ {
public:
explicit My_money_io_a(size_t r = 0): std::moneypunct<char,false>(r) { }
char_type do_decimal_point() const { return '.'; } char_type do_decimal_point() const { return '.'; }
char_type do_thousands_sep() const { return ','; }
std::string do_grouping() const { return "\004"; } std::string do_grouping() const { return "\004"; }
std::string do_curr_symbol() const { return "$"; } std::string do_curr_symbol() const { return "$"; }
...@@ -439,12 +466,9 @@ public: ...@@ -439,12 +466,9 @@ public:
} }
}; };
class My_money_io_b : public std::moneypunct<char,false> struct My_money_io_b : public std::moneypunct<char,false>
{ {
public:
explicit My_money_io_b(size_t r = 0): std::moneypunct<char,false>(r) { }
char_type do_decimal_point() const { return '.'; } char_type do_decimal_point() const { return '.'; }
char_type do_thousands_sep() const { return ','; }
std::string do_grouping() const { return "\004"; } std::string do_grouping() const { return "\004"; }
std::string do_curr_symbol() const { return "$"; } std::string do_curr_symbol() const { return "$"; }
......
...@@ -171,6 +171,36 @@ void test01() ...@@ -171,6 +171,36 @@ void test01()
mon_get.get(is_it11, end, true, iss, err11, result11); mon_get.get(is_it11, end, true, iss, err11, result11);
VERIFY( result11 == digits4 ); VERIFY( result11 == digits4 );
VERIFY( err11 == ios_base::goodbit ); 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() ...@@ -311,12 +341,9 @@ void test04()
#endif #endif
} }
class My_money_io : public std::moneypunct<wchar_t,false> struct My_money_io : public std::moneypunct<wchar_t,false>
{ {
public:
explicit My_money_io(size_t r = 0): std::moneypunct<wchar_t,false>(r) { }
char_type do_decimal_point() const { return L'.'; } char_type do_decimal_point() const { return L'.'; }
char_type do_thousands_sep() const { return L','; }
std::string do_grouping() const { return "\004"; } std::string do_grouping() const { return "\004"; }
std::wstring do_curr_symbol() const { return L"$"; } std::wstring do_curr_symbol() const { return L"$"; }
...@@ -385,6 +412,9 @@ void test05() ...@@ -385,6 +412,9 @@ void test05()
VERIFY( valn_ns == L"-123456" ); 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() void test06()
{ {
using namespace std; using namespace std;
...@@ -421,12 +451,9 @@ void test06() ...@@ -421,12 +451,9 @@ void test06()
VERIFY( val == buffer3 ); VERIFY( val == buffer3 );
} }
class My_money_io_a : public std::moneypunct<wchar_t,false> struct My_money_io_a : public std::moneypunct<wchar_t,false>
{ {
public:
explicit My_money_io_a(size_t r = 0): std::moneypunct<wchar_t,false>(r) { }
char_type do_decimal_point() const { return L'.'; } char_type do_decimal_point() const { return L'.'; }
char_type do_thousands_sep() const { return L','; }
std::string do_grouping() const { return "\004"; } std::string do_grouping() const { return "\004"; }
std::wstring do_curr_symbol() const { return L"$"; } std::wstring do_curr_symbol() const { return L"$"; }
...@@ -441,12 +468,9 @@ public: ...@@ -441,12 +468,9 @@ public:
} }
}; };
class My_money_io_b : public std::moneypunct<wchar_t,false> struct My_money_io_b : public std::moneypunct<wchar_t,false>
{ {
public:
explicit My_money_io_b(size_t r = 0): std::moneypunct<wchar_t,false>(r) { }
char_type do_decimal_point() const { return L'.'; } char_type do_decimal_point() const { return L'.'; }
char_type do_thousands_sep() const { return L','; }
std::string do_grouping() const { return "\004"; } std::string do_grouping() const { return "\004"; }
std::wstring do_curr_symbol() const { return L"$"; } std::wstring do_curr_symbol() const { return L"$"; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment