diff options
Diffstat (limited to 'libstdc++-v3/testsuite/22_locale/num_put_members_wchar_t.cc')
-rw-r--r-- | libstdc++-v3/testsuite/22_locale/num_put_members_wchar_t.cc | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/22_locale/num_put_members_wchar_t.cc b/libstdc++-v3/testsuite/22_locale/num_put_members_wchar_t.cc index 4fbf25f2121..53fdd591b5b 100644 --- a/libstdc++-v3/testsuite/22_locale/num_put_members_wchar_t.cc +++ b/libstdc++-v3/testsuite/22_locale/num_put_members_wchar_t.cc @@ -325,6 +325,43 @@ void test04() VERIFY( preLANG == postLANG ); } } + +// Make sure that, in a locale that expects grouping, when showbase +// is true, an hexadecimal or octal zero is correctly output (the case +// of zero is special since there is no 0x, 0 respectively, prefix) +void test05() +{ + using namespace std; + bool test = true; + + // A locale that expects grouping. + locale loc_de("de_DE"); + + const wstring empty; + wstring result; + + wostringstream oss; + oss.imbue(loc_de); + const num_put<wchar_t>& np = use_facet<num_put<wchar_t> >(oss.getloc()); + + long l = 0; + + oss.str(empty); + oss.clear(); + oss.setf(ios::showbase); + oss.setf(ios::hex, ios::basefield); + np.put(oss.rdbuf(), oss, L'+', l); + result = oss.str(); + VERIFY( result == L"0" ); + + oss.str(empty); + oss.clear(); + oss.setf(ios::showbase); + oss.setf(ios::oct, ios::basefield); + np.put(oss.rdbuf(), oss, L'+', l); + result = oss.str(); + VERIFY( result == L"0" ); +} #endif int main() @@ -334,6 +371,7 @@ int main() test02(); test03(); test04(); + test05(); #endif return 0; } |