diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index c47d7f0e1d1..d8ccc58523d 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,12 @@ +2002-03-02 Paolo Carlini + + * testsuite/22_locale/num_get_members_char.cc (test04): + Use a named locale expecting grouping (de_DE). + * testsuite/22_locale/num_get_members_wchar_t.cc (test04): + Ditto. + * testsuite/27_io/ios_manip_basefield.cc (test01): + Extend coverage, uniform treatment of hexs and octs. + 2002-02-28 Richard Henderson * config/linker-map.gnu: Export operator new with unsigned long, diff --git a/libstdc++-v3/testsuite/22_locale/num_get_members_char.cc b/libstdc++-v3/testsuite/22_locale/num_get_members_char.cc index 8907d08ba22..e8f2219543c 100644 --- a/libstdc++-v3/testsuite/22_locale/num_get_members_char.cc +++ b/libstdc++-v3/testsuite/22_locale/num_get_members_char.cc @@ -332,15 +332,6 @@ void test03() #endif } -struct MyNP : std::numpunct -{ - std::string do_grouping() const; - char do_thousands_sep() const; -}; - -std::string MyNP::do_grouping() const { std::string s("\3"); return s; } -char MyNP::do_thousands_sep() const { return ' '; } - // Testing the correct parsing of grouped hexadecimals and octals. void test04() { @@ -351,49 +342,52 @@ void test04() unsigned long ul; istringstream iss; - iss.imbue(locale(locale(), new MyNP)); + + // A locale that expects grouping + locale loc_de("de_DE"); + iss.imbue(loc_de); const num_get& ng = use_facet >(iss.getloc()); const ios_base::iostate goodbit = ios_base::goodbit; ios_base::iostate err = ios_base::goodbit; iss.setf(ios::hex, ios::basefield); - iss.str("0xbf fff 74c."); + iss.str("0xbf.fff.74c "); err = goodbit; ng.get(iss.rdbuf(), 0, iss, err, ul); VERIFY( err == goodbit ); VERIFY( ul == 0xbffff74c ); - iss.str("0Xf fff."); + iss.str("0Xf.fff "); err = goodbit; ng.get(iss.rdbuf(), 0, iss, err, ul); VERIFY( err == goodbit ); VERIFY( ul == 0xffff ); - iss.str("f ffe."); + iss.str("ffe "); err = goodbit; ng.get(iss.rdbuf(), 0, iss, err, ul); VERIFY( err == goodbit ); - VERIFY( ul == 0xfffe ); + VERIFY( ul == 0xffe ); iss.setf(ios::oct, ios::basefield); - iss.str("07 654 321."); + iss.str("07.654.321 "); err = goodbit; ng.get(iss.rdbuf(), 0, iss, err, ul); VERIFY( err == goodbit ); VERIFY( ul == 07654321 ); - iss.str("07 777."); + iss.str("07.777 "); err = goodbit; ng.get(iss.rdbuf(), 0, iss, err, ul); VERIFY( err == goodbit ); VERIFY( ul == 07777 ); - iss.str("7 776."); + iss.str("776 "); err = goodbit; ng.get(iss.rdbuf(), 0, iss, err, ul); VERIFY( err == goodbit ); - VERIFY( ul == 07776 ); + VERIFY( ul == 0776 ); } int main() diff --git a/libstdc++-v3/testsuite/22_locale/num_get_members_wchar_t.cc b/libstdc++-v3/testsuite/22_locale/num_get_members_wchar_t.cc index cbd39aefd9d..807fb5b1474 100644 --- a/libstdc++-v3/testsuite/22_locale/num_get_members_wchar_t.cc +++ b/libstdc++-v3/testsuite/22_locale/num_get_members_wchar_t.cc @@ -334,15 +334,6 @@ void test03() #endif } -struct MyNP : std::numpunct -{ - std::string do_grouping() const; - wchar_t do_thousands_sep() const; -}; - -std::string MyNP::do_grouping() const { std::string s("\3"); return s; } -wchar_t MyNP::do_thousands_sep() const { return L' '; } - // Testing the correct parsing of grouped hexadecimals and octals. void test04() { @@ -353,49 +344,52 @@ void test04() unsigned long ul; wistringstream iss; - iss.imbue(locale(locale(), new MyNP)); + + // A locale that expects grouping + locale loc_de("de_DE"); + iss.imbue(loc_de); const num_get& ng = use_facet >(iss.getloc()); const ios_base::iostate goodbit = ios_base::goodbit; ios_base::iostate err = ios_base::goodbit; iss.setf(ios::hex, ios::basefield); - iss.str(L"0xbf fff 74c."); + iss.str(L"0xbf.fff.74c "); err = goodbit; ng.get(iss.rdbuf(), 0, iss, err, ul); VERIFY( err == goodbit ); VERIFY( ul == 0xbffff74c ); - iss.str(L"0Xf fff."); + iss.str(L"0Xf.fff "); err = goodbit; ng.get(iss.rdbuf(), 0, iss, err, ul); VERIFY( err == goodbit ); VERIFY( ul == 0xffff ); - iss.str(L"f ffe."); + iss.str(L"ffe "); err = goodbit; ng.get(iss.rdbuf(), 0, iss, err, ul); VERIFY( err == goodbit ); - VERIFY( ul == 0xfffe ); + VERIFY( ul == 0xffe ); iss.setf(ios::oct, ios::basefield); - iss.str(L"07 654 321."); + iss.str(L"07.654.321 "); err = goodbit; ng.get(iss.rdbuf(), 0, iss, err, ul); VERIFY( err == goodbit ); VERIFY( ul == 07654321 ); - iss.str(L"07 777."); + iss.str(L"07.777 "); err = goodbit; ng.get(iss.rdbuf(), 0, iss, err, ul); VERIFY( err == goodbit ); VERIFY( ul == 07777 ); - iss.str(L"7 776."); + iss.str(L"776 "); err = goodbit; ng.get(iss.rdbuf(), 0, iss, err, ul); VERIFY( err == goodbit ); - VERIFY( ul == 07776 ); + VERIFY( ul == 0776 ); } #endif diff --git a/libstdc++-v3/testsuite/27_io/ios_manip_basefield.cc b/libstdc++-v3/testsuite/27_io/ios_manip_basefield.cc index 1ce1d087f10..82aeeaa0c74 100644 --- a/libstdc++-v3/testsuite/27_io/ios_manip_basefield.cc +++ b/libstdc++-v3/testsuite/27_io/ios_manip_basefield.cc @@ -47,12 +47,15 @@ test01() bool test = true; const char lit[] = "0123 456\n: 01 234 567:\n:0123 456 :\n" - ": 012 345:\n: 01 234:\n: 04 553 207:\n" - ":0361 100 :\n: 030 071:\n: 02 322:\n" - "0x000012 345 678\n"; + ": 012 345:\n: 01 234:\n:0726 746 425:\n" + ":04 553 207 :\n: 0361 100:\n: 0173:\n" + "0x12 345 678\n|0x000012 345 678|\n|0x12 345 6780000|\n" + "|00000x12 345 678|\n|0x000012 345 678|\n"; std::ostringstream oss; oss.imbue(std::locale(std::locale(), new MyNP)); + + // Octals oss << std::oct << std::showbase; oss << 0123456l << std::endl; @@ -69,24 +72,33 @@ test01() oss << 01234l << ":" << std::endl; oss << ":" << std::setw(11); - oss << 1234567l << ":" << std::endl; + oss << 123456789l << ":" << std::endl; oss << ":" << std::setw(11) << std::left; - oss << 123456l << ":" << std::endl; + oss << 1234567l << ":" << std::endl; oss << ":" << std::setw(11) << std::right; - oss << 12345l << ":" << std::endl; + oss << 123456l << ":" << std::endl; oss << ":" << std::setw(11) << std::internal; - oss << 1234l << ":" << std::endl; + oss << 123l << ":" << std::endl; - oss << std::hex; - oss << std::setfill('0'); - oss << std::internal; - oss << std::showbase; - oss << std::setw(16); + // Hexadecimals + oss << std::hex << std::setfill('0'); oss << 0x12345678l << std::endl; + oss << "|" << std::setw(16); + oss << 0x12345678l << "|" << std::endl; + + oss << "|" << std::setw(16) << std::left; + oss << 0x12345678l << "|" << std::endl; + + oss << "|" << std::setw(16) << std::right; + oss << 0x12345678l << "|" << std::endl; + + oss << "|" << std::setw(16) << std::internal; + oss << 0x12345678l << "|" << std::endl; + VERIFY( oss.good() ); VERIFY( oss.str() == lit ); @@ -133,9 +145,13 @@ main() :0123 456 : : 012 345: : 01 234: -: 04 553 207: -:0361 100 : -: 030 071: -: 02 322: -0x000012 345 678 +:0726 746 425: +:04 553 207 : +: 0361 100: +: 0173: +0x12 345 678 +|0x000012 345 678| +|0x12 345 6780000| +|00000x12 345 678| +|0x000012 345 678| */