diff options
author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-12-31 08:28:10 +0000 |
---|---|---|
committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-12-31 08:28:10 +0000 |
commit | 4c5a278eabd0fabad8beb380b04d449f5207a40d (patch) | |
tree | dc615e287c0bd2140978df6b1f24cda3d7812fb3 /libstdc++-v3/testsuite/22_locale | |
parent | 11b3eb0ff9eb26d022a0911829f43737a8e9791d (diff) | |
download | gcc-4c5a278eabd0fabad8beb380b04d449f5207a40d.tar.gz |
2003-12-31 Paolo Carlini <pcarlini@suse.de>
* include/bits/locale_facets.tcc (num_get::_M_extract_int,
num_get::_M_extract_float): According to 22.2.2.1.2, p8-9,
_first_ look for thousands_sep, then for decimal_point and
finally for digits.
(num_get::_M_extract_float): After the decimal_point or
'e'/'E', decimal_point and thousands_sep just break out the
parsing loop.
* testsuite/22_locale/num_get/get/char/11.cc: Add tests.
* testsuite/22_locale/num_get/get/wchar_t/11.cc: Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@75259 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite/22_locale')
-rw-r--r-- | libstdc++-v3/testsuite/22_locale/num_get/get/char/11.cc | 59 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/11.cc | 59 |
2 files changed, 98 insertions, 20 deletions
diff --git a/libstdc++-v3/testsuite/22_locale/num_get/get/char/11.cc b/libstdc++-v3/testsuite/22_locale/num_get/get/char/11.cc index 138f10d0a0c..f9bd9331809 100644 --- a/libstdc++-v3/testsuite/22_locale/num_get/get/char/11.cc +++ b/libstdc++-v3/testsuite/22_locale/num_get/get/char/11.cc @@ -22,13 +22,20 @@ #include <sstream> #include <testsuite_hooks.h> -struct Punct: std::numpunct<char> +struct Punct1: std::numpunct<char> { std::string do_grouping() const { return "\1"; } char do_thousands_sep() const { return '2'; } char do_decimal_point() const { return '4'; } }; +struct Punct2: std::numpunct<char> +{ + std::string do_grouping() const { return "\1"; } + char do_thousands_sep() const { return '2'; } + char do_decimal_point() const { return '2'; } +}; + // http://gcc.gnu.org/ml/libstdc++/2003-12/msg00201.html void test01() { @@ -37,30 +44,62 @@ void test01() bool test __attribute__((unused)) = true; - istringstream iss; - iss.imbue(locale(iss.getloc(), static_cast<numpunct<char>*>(new Punct))); - const num_get<char>& ng = use_facet<num_get<char> >(iss.getloc()); + istringstream iss1, iss2; + iss1.imbue(locale(iss1.getloc(), static_cast<numpunct<char>*>(new Punct1))); + iss2.imbue(locale(iss2.getloc(), static_cast<numpunct<char>*>(new Punct2))); + const num_get<char>& ng1 = use_facet<num_get<char> >(iss1.getloc()); + const num_get<char>& ng2 = use_facet<num_get<char> >(iss2.getloc()); + ios_base::iostate err = ios_base::goodbit; iterator_type end; double d = 0.0; double d1 = 13.0; + double d2 = 1.0; + double d3 = 30.0; long l = 0l; long l1 = 13l; + long l2 = 10l; - iss.str("1234"); + iss1.str("1234"); err = ios_base::goodbit; - end = ng.get(iss.rdbuf(), 0, iss, err, d); + end = ng1.get(iss1.rdbuf(), 0, iss1, err, d); VERIFY( err == ios_base::eofbit ); VERIFY( d == d1 ); - iss.str("1234"); - iss.clear(); + iss1.str("142"); + iss1.clear(); + err = ios_base::goodbit; + end = ng1.get(iss1.rdbuf(), 0, iss1, err, d); + VERIFY( err == ios_base::goodbit ); + VERIFY( d == d2 ); + + iss1.str("3e14"); + iss1.clear(); + err = ios_base::goodbit; + end = ng1.get(iss1.rdbuf(), 0, iss1, err, d); + VERIFY( err == ios_base::goodbit ); + VERIFY( d == d3 ); + + iss1.str("1234"); + iss1.clear(); err = ios_base::goodbit; - end = ng.get(iss.rdbuf(), 0, iss, err, l); + end = ng1.get(iss1.rdbuf(), 0, iss1, err, l); VERIFY( err == ios_base::goodbit ); VERIFY( l == l1 ); -} + iss2.str("123"); + err = ios_base::goodbit; + end = ng2.get(iss2.rdbuf(), 0, iss2, err, d); + VERIFY( err == ios_base::eofbit ); + VERIFY( d == d1 ); + + iss2.str("120"); + iss2.clear(); + err = ios_base::goodbit; + end = ng2.get(iss2.rdbuf(), 0, iss2, err, l); + VERIFY( err == ios_base::eofbit ); + VERIFY( l == l2 ); +} int main() { diff --git a/libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/11.cc b/libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/11.cc index d478209f49d..d056892856e 100644 --- a/libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/11.cc +++ b/libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/11.cc @@ -22,13 +22,20 @@ #include <sstream> #include <testsuite_hooks.h> -struct Punct: std::numpunct<wchar_t> +struct Punct1: std::numpunct<wchar_t> { std::string do_grouping() const { return "\1"; } wchar_t do_thousands_sep() const { return L'2'; } wchar_t do_decimal_point() const { return L'4'; } }; +struct Punct2: std::numpunct<wchar_t> +{ + std::string do_grouping() const { return "\1"; } + wchar_t do_thousands_sep() const { return L'2'; } + wchar_t do_decimal_point() const { return L'2'; } +}; + // http://gcc.gnu.org/ml/libstdc++/2003-12/msg00201.html void test01() { @@ -37,30 +44,62 @@ void test01() bool test __attribute__((unused)) = true; - wistringstream iss; - iss.imbue(locale(iss.getloc(), static_cast<numpunct<wchar_t>*>(new Punct))); - const num_get<wchar_t>& ng = use_facet<num_get<wchar_t> >(iss.getloc()); + wistringstream iss1, iss2; + iss1.imbue(locale(iss1.getloc(), static_cast<numpunct<wchar_t>*>(new Punct1))); + iss2.imbue(locale(iss2.getloc(), static_cast<numpunct<wchar_t>*>(new Punct2))); + const num_get<wchar_t>& ng1 = use_facet<num_get<wchar_t> >(iss1.getloc()); + const num_get<wchar_t>& ng2 = use_facet<num_get<wchar_t> >(iss2.getloc()); + ios_base::iostate err = ios_base::goodbit; iterator_type end; double d = 0.0; double d1 = 13.0; + double d2 = 1.0; + double d3 = 30.0; long l = 0l; long l1 = 13l; + long l2 = 10l; - iss.str(L"1234"); + iss1.str(L"1234"); err = ios_base::goodbit; - end = ng.get(iss.rdbuf(), 0, iss, err, d); + end = ng1.get(iss1.rdbuf(), 0, iss1, err, d); VERIFY( err == ios_base::eofbit ); VERIFY( d == d1 ); - iss.str(L"1234"); - iss.clear(); + iss1.str(L"142"); + iss1.clear(); + err = ios_base::goodbit; + end = ng1.get(iss1.rdbuf(), 0, iss1, err, d); + VERIFY( err == ios_base::goodbit ); + VERIFY( d == d2 ); + + iss1.str(L"3e14"); + iss1.clear(); + err = ios_base::goodbit; + end = ng1.get(iss1.rdbuf(), 0, iss1, err, d); + VERIFY( err == ios_base::goodbit ); + VERIFY( d == d3 ); + + iss1.str(L"1234"); + iss1.clear(); err = ios_base::goodbit; - end = ng.get(iss.rdbuf(), 0, iss, err, l); + end = ng1.get(iss1.rdbuf(), 0, iss1, err, l); VERIFY( err == ios_base::goodbit ); VERIFY( l == l1 ); -} + iss2.str(L"123"); + err = ios_base::goodbit; + end = ng2.get(iss2.rdbuf(), 0, iss2, err, d); + VERIFY( err == ios_base::eofbit ); + VERIFY( d == d1 ); + + iss2.str(L"120"); + iss2.clear(); + err = ios_base::goodbit; + end = ng2.get(iss2.rdbuf(), 0, iss2, err, l); + VERIFY( err == ios_base::eofbit ); + VERIFY( l == l2 ); +} int main() { |