aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorPaolo Carlini <pcarlini@unitus.it>2002-03-02 22:32:56 +0100
committerPaolo Carlini <paolo@gcc.gnu.org>2002-03-02 21:32:56 +0000
commit658499e7b47d6d99673f4f1cf297d43e940ec21e (patch)
tree627c4acf284029105808f6bf1b9f0207ff44534f /libstdc++-v3
parentfd87b7a7099bc82b2542b169c592c0dfc997029e (diff)
downloadgcc-658499e7b47d6d99673f4f1cf297d43e940ec21e.zip
gcc-658499e7b47d6d99673f4f1cf297d43e940ec21e.tar.gz
gcc-658499e7b47d6d99673f4f1cf297d43e940ec21e.tar.bz2
num_get_members_char.cc (test04): Use a named locale expecting grouping (de_DE).
2002-03-02 Paolo Carlini <pcarlini@unitus.it> * 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. From-SVN: r50234
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog9
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_get_members_char.cc30
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_get_members_wchar_t.cc30
-rw-r--r--libstdc++-v3/testsuite/27_io/ios_manip_basefield.cc50
4 files changed, 66 insertions, 53 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index c47d7f0..d8ccc58 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,12 @@
+2002-03-02 Paolo Carlini <pcarlini@unitus.it>
+
+ * 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 <rth@redhat.com>
* 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 8907d08..e8f2219 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<char>
-{
- 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<char>& ng = use_facet<num_get<char> >(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 cbd39ae..807fb5b 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<wchar_t>
-{
- 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<wchar_t>& ng = use_facet<num_get<wchar_t> >(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 1ce1d08..82aeeaa 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|
*/