From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- .../testsuite/22_locale/money_get/get/char/1.cc | 125 +++++++++++++++++++++ .../testsuite/22_locale/money_get/get/char/10.cc | 64 +++++++++++ .../testsuite/22_locale/money_get/get/char/11.cc | 64 +++++++++++ .../22_locale/money_get/get/char/11528.cc | 54 +++++++++ .../testsuite/22_locale/money_get/get/char/12.cc | 71 ++++++++++++ .../testsuite/22_locale/money_get/get/char/13.cc | 68 +++++++++++ .../testsuite/22_locale/money_get/get/char/14.cc | 61 ++++++++++ .../testsuite/22_locale/money_get/get/char/15.cc | 69 ++++++++++++ .../testsuite/22_locale/money_get/get/char/16.cc | 77 +++++++++++++ .../testsuite/22_locale/money_get/get/char/17.cc | 72 ++++++++++++ .../testsuite/22_locale/money_get/get/char/18.cc | 70 ++++++++++++ .../testsuite/22_locale/money_get/get/char/19.cc | 124 ++++++++++++++++++++ .../testsuite/22_locale/money_get/get/char/2.cc | 118 +++++++++++++++++++ .../22_locale/money_get/get/char/22131.cc | 82 ++++++++++++++ .../testsuite/22_locale/money_get/get/char/3.cc | 71 ++++++++++++ .../22_locale/money_get/get/char/38399.cc | 54 +++++++++ .../22_locale/money_get/get/char/39168.cc | 56 +++++++++ .../testsuite/22_locale/money_get/get/char/4.cc | 66 +++++++++++ .../testsuite/22_locale/money_get/get/char/5.cc | 70 ++++++++++++ .../testsuite/22_locale/money_get/get/char/6.cc | 97 ++++++++++++++++ .../testsuite/22_locale/money_get/get/char/7.cc | 72 ++++++++++++ .../testsuite/22_locale/money_get/get/char/8.cc | 122 ++++++++++++++++++++ .../testsuite/22_locale/money_get/get/char/9.cc | 90 +++++++++++++++ .../22_locale/money_get/get/char/wrapped_env.cc | 74 ++++++++++++ .../22_locale/money_get/get/char/wrapped_locale.cc | 74 ++++++++++++ 25 files changed, 1965 insertions(+) create mode 100644 libstdc++-v3/testsuite/22_locale/money_get/get/char/1.cc create mode 100644 libstdc++-v3/testsuite/22_locale/money_get/get/char/10.cc create mode 100644 libstdc++-v3/testsuite/22_locale/money_get/get/char/11.cc create mode 100644 libstdc++-v3/testsuite/22_locale/money_get/get/char/11528.cc create mode 100644 libstdc++-v3/testsuite/22_locale/money_get/get/char/12.cc create mode 100644 libstdc++-v3/testsuite/22_locale/money_get/get/char/13.cc create mode 100644 libstdc++-v3/testsuite/22_locale/money_get/get/char/14.cc create mode 100644 libstdc++-v3/testsuite/22_locale/money_get/get/char/15.cc create mode 100644 libstdc++-v3/testsuite/22_locale/money_get/get/char/16.cc create mode 100644 libstdc++-v3/testsuite/22_locale/money_get/get/char/17.cc create mode 100644 libstdc++-v3/testsuite/22_locale/money_get/get/char/18.cc create mode 100644 libstdc++-v3/testsuite/22_locale/money_get/get/char/19.cc create mode 100644 libstdc++-v3/testsuite/22_locale/money_get/get/char/2.cc create mode 100644 libstdc++-v3/testsuite/22_locale/money_get/get/char/22131.cc create mode 100644 libstdc++-v3/testsuite/22_locale/money_get/get/char/3.cc create mode 100644 libstdc++-v3/testsuite/22_locale/money_get/get/char/38399.cc create mode 100644 libstdc++-v3/testsuite/22_locale/money_get/get/char/39168.cc create mode 100644 libstdc++-v3/testsuite/22_locale/money_get/get/char/4.cc create mode 100644 libstdc++-v3/testsuite/22_locale/money_get/get/char/5.cc create mode 100644 libstdc++-v3/testsuite/22_locale/money_get/get/char/6.cc create mode 100644 libstdc++-v3/testsuite/22_locale/money_get/get/char/7.cc create mode 100644 libstdc++-v3/testsuite/22_locale/money_get/get/char/8.cc create mode 100644 libstdc++-v3/testsuite/22_locale/money_get/get/char/9.cc create mode 100644 libstdc++-v3/testsuite/22_locale/money_get/get/char/wrapped_env.cc create mode 100644 libstdc++-v3/testsuite/22_locale/money_get/get/char/wrapped_locale.cc (limited to 'libstdc++-v3/testsuite/22_locale/money_get/get/char') diff --git a/libstdc++-v3/testsuite/22_locale/money_get/get/char/1.cc b/libstdc++-v3/testsuite/22_locale/money_get/get/char/1.cc new file mode 100644 index 000000000..e76e07694 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/money_get/get/char/1.cc @@ -0,0 +1,125 @@ +// { dg-require-namedlocale "de_DE@euro" } + +// 2001-09-12 Benjamin Kosnik + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 22.2.6.1.1 money_get members + +#include +#include +#include + +// test string version +void test01() +{ + using namespace std; + typedef istreambuf_iterator iterator_type; + + bool test __attribute__((unused)) = true; + + // basic construction + locale loc_c = locale::classic(); + locale loc_de = locale("de_DE@euro"); + VERIFY( loc_c != loc_de ); + + // sanity check the data is correct. + const string empty; + + // total EPA budget FY 2002 + const string digits1("720000000000"); + + iterator_type end; + istringstream iss; + iss.imbue(loc_de); + // cache the money_get facet + const money_get& mon_get = use_facet >(iss.getloc()); + + iss.str("7.200.000.000,00 "); + iterator_type is_it01(iss); + string result1; + ios_base::iostate err01 = ios_base::goodbit; + mon_get.get(is_it01, end, true, iss, err01, result1); // xxx + VERIFY( result1 == digits1 ); + VERIFY( err01 == ios_base::eofbit ); + + iss.str("7.200.000.000,00 "); + iterator_type is_it02(iss); + string result2; + ios_base::iostate err02 = ios_base::goodbit; + mon_get.get(is_it02, end, true, iss, err02, result2); + VERIFY( result2 == digits1 ); + VERIFY( err02 == ios_base::eofbit ); + + iss.str("7.200.000.000,00 a"); + iterator_type is_it03(iss); + string result3; + ios_base::iostate err03 = ios_base::goodbit; + mon_get.get(is_it03, end, true, iss, err03, result3); + VERIFY( result3 == digits1 ); + VERIFY( err03 == ios_base::goodbit ); + + iss.str(""); + iterator_type is_it04(iss); + string result4; + ios_base::iostate err04 = ios_base::goodbit; + mon_get.get(is_it04, end, true, iss, err04, result4); + VERIFY( result4 == empty ); + VERIFY( err04 == (ios_base::failbit | ios_base::eofbit) ); + + iss.str("working for enlightenment and peace in a mad world"); + iterator_type is_it05(iss); + string result5; + ios_base::iostate err05 = ios_base::goodbit; + mon_get.get(is_it05, end, true, iss, err05, result5); + VERIFY( result5 == empty ); + VERIFY( err05 == ios_base::failbit ); + + // now try with showbase, to get currency symbol in format + iss.setf(ios_base::showbase); + + iss.str("7.200.000.000,00 EUR "); + iterator_type is_it06(iss); + string result6; + ios_base::iostate err06 = ios_base::goodbit; + mon_get.get(is_it06, end, true, iss, err06, result6); + VERIFY( result6 == digits1 ); + VERIFY( err06 == ios_base::eofbit ); + + iss.str("7.200.000.000,00 EUR "); // Extra space. + iterator_type is_it07(iss); + string result7; + ios_base::iostate err07 = ios_base::goodbit; + mon_get.get(is_it07, end, true, iss, err07, result7); + VERIFY( result7 == digits1 ); + VERIFY( err07 == ios_base::goodbit ); + + iss.str("7.200.000.000,00 \244"); + iterator_type is_it08(iss); + string result8; + ios_base::iostate err08 = ios_base::goodbit; + mon_get.get(is_it08, end, false, iss, err08, result8); + VERIFY( result8 == digits1 ); + VERIFY( err08 == ios_base::eofbit ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/money_get/get/char/10.cc b/libstdc++-v3/testsuite/22_locale/money_get/get/char/10.cc new file mode 100644 index 000000000..5b4309d09 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/money_get/get/char/10.cc @@ -0,0 +1,64 @@ +// { dg-require-namedlocale "en_US" } + +// 2003-10-23 Paolo Carlini + +// Copyright (C) 2003, 2005, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 22.2.6.1.1 money_get members + +#include +#include +#include + +void test01() +{ + using namespace std; + typedef istreambuf_iterator iterator_type; + + bool test __attribute__((unused)) = true; + + locale loc_us = locale("en_US"); + + iterator_type end; + istringstream iss; + iss.imbue(loc_us); + + const money_get& mon_get = use_facet >(iss.getloc()); + + iss.str("-$0 "); + iterator_type is_it(iss); + string extracted_amount; + ios_base::iostate err = ios_base::goodbit; + mon_get.get(is_it, end, false, iss, err, extracted_amount); + VERIFY( extracted_amount == "0" ); + VERIFY( err == ios_base::goodbit ); + + iss.str("-$ "); + iterator_type is_it_2(iss); + extracted_amount.clear(); + err = ios_base::goodbit; + mon_get.get(is_it_2, end, false, iss, err, extracted_amount); + VERIFY( extracted_amount.empty() ); + VERIFY( err == ios_base::failbit ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/money_get/get/char/11.cc b/libstdc++-v3/testsuite/22_locale/money_get/get/char/11.cc new file mode 100644 index 000000000..e447e7780 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/money_get/get/char/11.cc @@ -0,0 +1,64 @@ +// { dg-require-namedlocale "de_DE@euro" } + +// 2003-10-24 Paolo Carlini + +// Copyright (C) 2003, 2005, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 22.2.6.1.1 money_get members + +#include +#include +#include +#include + +void test01() +{ + using namespace std; + typedef istreambuf_iterator iterator_type; + + bool test __attribute__((unused)) = true; + + // basic construction + locale loc_de = locale("de_DE@euro"); + + iterator_type end; + istringstream iss; + iss.imbue(loc_de); + + // cache the money_get facet + const money_get& mon_get = use_facet >(iss.getloc()); + + // A _very_ big amount. + string str = "1"; + for (int i = 0; i < 2 * numeric_limits::digits10; ++i) + str += ".000"; + str += ",00 "; + + iss.str(str); + iterator_type is_it01(iss); + long double result1; + ios_base::iostate err01 = ios_base::goodbit; + mon_get.get(is_it01, end, true, iss, err01, result1); + VERIFY( err01 == ios_base::eofbit ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/money_get/get/char/11528.cc b/libstdc++-v3/testsuite/22_locale/money_get/get/char/11528.cc new file mode 100644 index 000000000..5354cda9f --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/money_get/get/char/11528.cc @@ -0,0 +1,54 @@ +// { dg-require-namedlocale "en_US" } + +// Copyright (C) 2003, 2005, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 22.2.6.1.1 money_get members + +#include +#include +#include + +void test01() +{ + using namespace std; + typedef istreambuf_iterator iterator_type; + + bool test __attribute__((unused)) = true; + + locale loc_us = locale("en_US"); + + iterator_type end; + istringstream iss; + iss.imbue(loc_us); + + const money_get& mon_get = use_facet >(iss.getloc()); + + iss.str("$.00 "); + iterator_type is_it(iss); + string extracted_amount; + ios_base::iostate err = ios_base::goodbit; + mon_get.get(is_it, end, false, iss, err, extracted_amount); + VERIFY( extracted_amount == "0" ); + VERIFY( err == ios_base::goodbit ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/money_get/get/char/12.cc b/libstdc++-v3/testsuite/22_locale/money_get/get/char/12.cc new file mode 100644 index 000000000..a50393e2a --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/money_get/get/char/12.cc @@ -0,0 +1,71 @@ +// { dg-require-namedlocale "de_DE@euro" } + +// 2004-02-05 Paolo Carlini + +// Copyright (C) 2004, 2005, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 22.2.6.1.1 money_get members + +#include +#include +#include + +// Same as 3.cc but no thousands-sep in input: they are always optional. +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef istreambuf_iterator iterator_type; + + // basic construction + locale loc_c = locale::classic(); + locale loc_de = locale("de_DE@euro"); + VERIFY( loc_c != loc_de ); + + // total EPA budget FY 2002 + const long double digits1 = 720000000000.0; + + iterator_type end; + istringstream iss; + iss.imbue(loc_de); + // cache the money_get facet + const money_get& mon_get = use_facet >(iss.getloc()); + + iss.str("7200000000,00 "); + iterator_type is_it01(iss); + long double result1; + ios_base::iostate err01 = ios_base::goodbit; + mon_get.get(is_it01, end, true, iss, err01, result1); + VERIFY( result1 == digits1 ); + VERIFY( err01 == ios_base::eofbit ); + + iss.str("7200000000,00 "); + iterator_type is_it02(iss); + long double result2; + ios_base::iostate err02 = ios_base::goodbit; + mon_get.get(is_it02, end, false, iss, err02, result2); + VERIFY( result2 == digits1 ); + VERIFY( err02 == ios_base::eofbit ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/money_get/get/char/13.cc b/libstdc++-v3/testsuite/22_locale/money_get/get/char/13.cc new file mode 100644 index 000000000..361e357ce --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/money_get/get/char/13.cc @@ -0,0 +1,68 @@ +// { dg-require-namedlocale "de_DE@euro" } + +// 2004-02-05 Paolo Carlini + +// Copyright (C) 2004, 2005, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 22.2.6.1.1 money_get members + +#include +#include +#include + +// No thousands-sep allowed after the decimal-point. +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef istreambuf_iterator iterator_type; + + // basic construction + locale loc_c = locale::classic(); + locale loc_de = locale("de_DE@euro"); + VERIFY( loc_c != loc_de ); + + iterator_type end01, end02; + istringstream iss; + iss.imbue(loc_de); + // cache the money_get facet + const money_get& mon_get = use_facet >(iss.getloc()); + + iss.str("500,1.0 "); + iterator_type is_it01(iss); + long double result1; + ios_base::iostate err01 = ios_base::goodbit; + end01 = mon_get.get(is_it01, end01, true, iss, err01, result1); + VERIFY( err01 == ios_base::failbit ); + VERIFY( *end01 == '.' ); + + iss.str("500,1.0 "); + iterator_type is_it02(iss); + long double result2; + ios_base::iostate err02 = ios_base::goodbit; + end02 = mon_get.get(is_it02, end02, false, iss, err02, result2); + VERIFY( err02 == ios_base::failbit ); + VERIFY( *end02 == '.' ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/money_get/get/char/14.cc b/libstdc++-v3/testsuite/22_locale/money_get/get/char/14.cc new file mode 100644 index 000000000..f5311cd64 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/money_get/get/char/14.cc @@ -0,0 +1,61 @@ +// 2004-02-21 Paolo Carlini + +// Copyright (C) 2004, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 22.2.6.1.1 money_get members + +#include +#include +#include + +struct My_money : public std::moneypunct +{ + std::string do_positive_sign() const { return "+"; } + std::string do_negative_sign() const { return ""; } +}; + +void test01() +{ + using namespace std; + typedef istreambuf_iterator InIt; + + bool test __attribute__((unused)) = true; + + locale loc(locale::classic(), new My_money); + + string buffer("69"); + + InIt iend; + ios_base::iostate err; + string val; + + const money_get& mg = + use_facet >(loc); + + istringstream fmt(buffer); + fmt.imbue(loc); + InIt ibeg(fmt); + mg.get(ibeg, iend, false, fmt, err, val); + VERIFY( val == "-69" ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/money_get/get/char/15.cc b/libstdc++-v3/testsuite/22_locale/money_get/get/char/15.cc new file mode 100644 index 000000000..1d10cfd84 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/money_get/get/char/15.cc @@ -0,0 +1,69 @@ +// { dg-require-namedlocale "de_DE@euro" } + +// 2004-03-01 Paolo Carlini + +// Copyright (C) 2004, 2005, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 22.2.6.1.1 money_get members + +#include +#include +#include + +// The grammar doesn't allow thousands separator at the beginning of a +// string, neither two consecutive thousands separators. +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef istreambuf_iterator iterator_type; + + // basic construction + locale loc_c = locale::classic(); + locale loc_de = locale("de_DE@euro"); + VERIFY( loc_c != loc_de ); + + iterator_type end01, end02; + istringstream iss; + iss.imbue(loc_de); + // cache the money_get facet + const money_get& mon_get = use_facet >(iss.getloc()); + + iss.str(".100"); + iterator_type is_it01(iss); + long double result1; + ios_base::iostate err01 = ios_base::goodbit; + end01 = mon_get.get(is_it01, end01, true, iss, err01, result1); + VERIFY( err01 == ios_base::failbit ); + VERIFY( *end01 == '.' ); + + iss.str("30..0"); + iterator_type is_it02(iss); + long double result2; + ios_base::iostate err02 = ios_base::goodbit; + end02 = mon_get.get(is_it02, end02, false, iss, err02, result2); + VERIFY( err02 == ios_base::failbit ); + VERIFY( *end02 == '.' ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/money_get/get/char/16.cc b/libstdc++-v3/testsuite/22_locale/money_get/get/char/16.cc new file mode 100644 index 000000000..54c0934b0 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/money_get/get/char/16.cc @@ -0,0 +1,77 @@ +// { dg-require-namedlocale "de_DE@euro" } +// { dg-require-namedlocale "en_HK" } + +// 2004-03-02 Paolo Carlini + +// Copyright (C) 2004, 2005, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 22.2.6.1.1 money_get members + +#include +#include +#include + +// Fail as soon as value digits are not present. +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef istreambuf_iterator iterator_type; + + // basic construction + locale loc_c = locale::classic(); + locale loc_de = locale("de_DE@euro"); + locale loc_hk = locale("en_HK"); + VERIFY( loc_hk != loc_de ); + VERIFY( loc_c != loc_hk ); + + iterator_type end01, end02; + istringstream iss01, iss02; + iss01.imbue(loc_de); + iss02.imbue(loc_hk); + + // cache the money_get facet + const money_get& mon_get_01 = + use_facet >(iss01.getloc()); + const money_get& mon_get_02 = + use_facet >(iss02.getloc()); + + iss01.setf(ios_base::showbase); + iss01.str("EUR "); + iterator_type is_it01(iss01); + long double result1; + ios_base::iostate err01 = ios_base::goodbit; + end01 = mon_get_01.get(is_it01, end01, true, iss01, err01, result1); + VERIFY( err01 == ios_base::failbit ); + VERIFY( *end01 == 'E' ); + + iss02.str("(HKD )"); + iterator_type is_it02(iss02); + long double result2; + ios_base::iostate err02 = ios_base::goodbit; + end02 = mon_get_02.get(is_it02, end02, true, iss02, err02, result2); + VERIFY( err02 == ios_base::failbit ); + VERIFY( *end02 == ')' ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/money_get/get/char/17.cc b/libstdc++-v3/testsuite/22_locale/money_get/get/char/17.cc new file mode 100644 index 000000000..530999e06 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/money_get/get/char/17.cc @@ -0,0 +1,72 @@ +// { dg-require-namedlocale "de_DE@euro" } + +// 2004-03-08 Paolo Carlini + +// Copyright (C) 2004, 2005, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 22.2.6.1.1 money_get members + +#include +#include +#include + +// 22.2.6.3, p2: "The value _space_ indicates that at least one space +// is required at that position." +void test01() +{ + using namespace std; + typedef istreambuf_iterator iterator_type; + + bool test __attribute__((unused)) = true; + + // basic construction + locale loc_c = locale::classic(); + locale loc_de = locale("de_DE@euro"); + VERIFY( loc_c != loc_de ); + + iterator_type end, end02; + istringstream iss; + iss.imbue(loc_de); + // cache the money_get facet + const money_get& mon_get = + use_facet >(iss.getloc()); + + iss.str("7.200.000.000,00"); + iterator_type is_it01(iss); + string result1; + ios_base::iostate err01 = ios_base::goodbit; + mon_get.get(is_it01, end, true, iss, err01, result1); + VERIFY( err01 == (ios_base::failbit | ios_base::eofbit) ); + + // now try with showbase, to get currency symbol in format + iss.setf(ios_base::showbase); + + iss.str("7.200.000.000,00EUR "); + iterator_type is_it02(iss); + string result2; + ios_base::iostate err02 = ios_base::goodbit; + end02 = mon_get.get(is_it02, end, true, iss, err02, result2); + VERIFY( err02 == ios_base::failbit ); + VERIFY( *end02 == 'E' ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/money_get/get/char/18.cc b/libstdc++-v3/testsuite/22_locale/money_get/get/char/18.cc new file mode 100644 index 000000000..f903a7596 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/money_get/get/char/18.cc @@ -0,0 +1,70 @@ +// { dg-require-namedlocale "en_HK" } + +// 2004-03-15 Paolo Carlini + +// Copyright (C) 2004, 2005, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 22.2.6.1.1 money_get members + +#include +#include +#include + +// If (str.flags() & str.showbase) is false, the currency symbol is optional, +// but, if found, must be consumed entirely. +void test01() +{ + using namespace std; + typedef istreambuf_iterator iterator_type; + + bool test __attribute__((unused)) = true; + + // basic construction + locale loc_c = locale::classic(); + locale loc_hk = locale("en_HK"); + VERIFY( loc_c != loc_hk ); + + iterator_type end, end01, end02; + istringstream iss; + iss.imbue(loc_hk); + // cache the money_get facet + const money_get& mon_get = + use_facet >(iss.getloc()); + + iss.str("HK7,200,000,000.00"); + iterator_type is_it01(iss); + string result01; + ios_base::iostate err01 = ios_base::goodbit; + end01 = mon_get.get(is_it01, end, false, iss, err01, result01); + VERIFY( err01 == ios_base::failbit ); + VERIFY( *end01 == '7' ); + + iss.str("(HK100,000,000,000.00)"); + iterator_type is_it02(iss); + string result02; + ios_base::iostate err02 = ios_base::goodbit; + end02 = mon_get.get(is_it02, end, true, iss, err02, result02); + VERIFY( err02 == ios_base::failbit ); + VERIFY( *end02 == '1' ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/money_get/get/char/19.cc b/libstdc++-v3/testsuite/22_locale/money_get/get/char/19.cc new file mode 100644 index 000000000..5ecc131d4 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/money_get/get/char/19.cc @@ -0,0 +1,124 @@ +// 2004-03-15 Paolo Carlini + +// Copyright (C) 2004, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 22.2.6.1.1 money_get members + +#include +#include +#include + +struct My_money_io_01 : public std::moneypunct +{ + std::string do_curr_symbol() const { return "$"; } + std::string do_positive_sign() const { return ""; } + std::string do_negative_sign() const { return ""; } + + pattern do_neg_format() const + { + pattern pat = { { value, symbol, none, sign } }; + return pat; + } +}; + +struct My_money_io_02 : public std::moneypunct +{ + std::string do_curr_symbol() const { return "%"; } + std::string do_positive_sign() const { return ""; } + std::string do_negative_sign() const { return "-"; } + + pattern do_neg_format() const + { + pattern pat = { { value, symbol, sign, none } }; + return pat; + } +}; + +struct My_money_io_03 : public std::moneypunct +{ + std::string do_curr_symbol() const { return "&"; } + std::string do_positive_sign() const { return ""; } + std::string do_negative_sign() const { return ""; } + + pattern do_neg_format() const + { + pattern pat = { { value, space, symbol, sign } }; + return pat; + } +}; + +// When both do_positive_sign and do_negative_sign return an empty +// string, patterns of the forms { value, symbol, none, sign }, +// { value, symbol, sign, none } and { X, Y, symbol, sign } imply +// that the symbol is not consumed since no other characters are +// needed to complete the format. +void test01() +{ + using namespace std; + typedef istreambuf_iterator iterator_type; + + bool test __attribute__((unused)) = true; + + // basic construction + locale loc_01(locale::classic(), new My_money_io_01); + locale loc_02(locale::classic(), new My_money_io_02); + locale loc_03(locale::classic(), new My_money_io_03); + + iterator_type end, end01, end02, end03; + istringstream iss_01, iss_02, iss_03; + iss_01.imbue(loc_01); + iss_02.imbue(loc_02); + iss_03.imbue(loc_03); + // cache the money_get facet + const money_get& mon_get_01 = + use_facet >(iss_01.getloc()); + const money_get& mon_get_02 = + use_facet >(iss_02.getloc()); + const money_get& mon_get_03 = + use_facet >(iss_03.getloc()); + + iss_01.str("10$"); + iterator_type is_it01(iss_01); + string result01; + ios_base::iostate err01 = ios_base::goodbit; + end01 = mon_get_01.get(is_it01, end, false, iss_01, err01, result01); + VERIFY( err01 == ios_base::goodbit ); + VERIFY( *end01 == '$' ); + + iss_02.str("50%"); + iterator_type is_it02(iss_02); + string result02; + ios_base::iostate err02 = ios_base::goodbit; + end02 = mon_get_02.get(is_it02, end, false, iss_02, err02, result02); + VERIFY( err02 == ios_base::goodbit ); + VERIFY( *end02 == '%' ); + + iss_03.str("7 &"); + iterator_type is_it03(iss_03); + string result03; + ios_base::iostate err03 = ios_base::goodbit; + end03 = mon_get_03.get(is_it03, end, false, iss_03, err03, result03); + VERIFY( err03 == ios_base::goodbit ); + VERIFY( *end03 == '&' ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/money_get/get/char/2.cc b/libstdc++-v3/testsuite/22_locale/money_get/get/char/2.cc new file mode 100644 index 000000000..c1b8e593b --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/money_get/get/char/2.cc @@ -0,0 +1,118 @@ +// { dg-require-namedlocale "en_HK" } + +// 2001-09-12 Benjamin Kosnik + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 22.2.6.1.1 money_get members + +#include +#include +#include + +// test string version +void test02() +{ + using namespace std; + typedef istreambuf_iterator iterator_type; + + bool test __attribute__((unused)) = true; + + // basic construction + locale loc_c = locale::classic(); + locale loc_hk = locale("en_HK"); + VERIFY( loc_c != loc_hk ); + + // total EPA budget FY 2002 + const string digits1("720000000000"); + + // est. cost, national missile "defense", expressed as a loss in USD 2001 + const string digits2("-10000000000000"); + + // input less than frac_digits + const string digits4("-1"); + + iterator_type end; + istringstream iss; + iss.imbue(loc_hk); + // cache the money_get facet + const money_get& mon_get = use_facet >(iss.getloc()); + + // now try with showbase, to get currency symbol in format + iss.setf(ios_base::showbase); + + iss.str("HK$7,200,000,000.00"); + iterator_type is_it09(iss); + string result9; + ios_base::iostate err09 = ios_base::goodbit; + mon_get.get(is_it09, end, false, iss, err09, result9); + VERIFY( result9 == digits1 ); + VERIFY( err09 == ios_base::eofbit ); + + iss.str("(HKD 100,000,000,000.00)"); + iterator_type is_it10(iss); + string result10; + ios_base::iostate err10 = ios_base::goodbit; + mon_get.get(is_it10, end, true, iss, err10, result10); + VERIFY( result10 == digits2 ); + VERIFY( err10 == ios_base::eofbit ); + + iss.str("(HKD .01)"); + iterator_type is_it11(iss); + string result11; + ios_base::iostate err11 = ios_base::goodbit; + mon_get.get(is_it11, end, true, iss, err11, result11); + VERIFY( result11 == digits4 ); + VERIFY( err11 == ios_base::eofbit ); + + // 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::eofbit ); + + 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::eofbit ); +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/money_get/get/char/22131.cc b/libstdc++-v3/testsuite/22_locale/money_get/get/char/22131.cc new file mode 100644 index 000000000..48acd2284 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/money_get/get/char/22131.cc @@ -0,0 +1,82 @@ +// 2005-06-28 Paolo Carlini + +// Copyright (C) 2005, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 22.2.6.1.1 money_get members + +#include +#include +#include + +struct My_money_io : public std::moneypunct +{ + std::string do_grouping() const { return "\1"; } + char_type do_thousands_sep() const { return '#'; } + + pattern do_neg_format() const + { + pattern pat = { { symbol, none, sign, value } }; + return pat; + } +}; + +// libstdc++/22131 +void test01() +{ + using namespace std; + typedef istreambuf_iterator InIt; + + bool test __attribute__((unused)) = true; + + locale loc(locale::classic(), new My_money_io); + + string buffer1("00#0#1"); + string buffer2("000##1"); + + bool intl = false; + + InIt iend1, iend2; + ios_base::iostate err1, err2; + string val1, val2; + + const money_get& mg = + use_facet >(loc); + + istringstream fmt1(buffer1); + fmt1.imbue(loc); + InIt ibeg1(fmt1); + err1 = ios_base::goodbit; + mg.get(ibeg1, iend1, intl, fmt1, err1, val1); + VERIFY( err1 == (ios_base::eofbit | ios_base::failbit) ); + VERIFY( val1 == "1" ); + + istringstream fmt2(buffer2); + fmt2.imbue(loc); + InIt ibeg2(fmt2); + err2 = ios_base::goodbit; + mg.get(ibeg2, iend2, intl, fmt2, err2, val2); + VERIFY( err2 == ios_base::failbit ); + VERIFY( *ibeg2 == '#' ); + VERIFY( val2 == "" ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/money_get/get/char/3.cc b/libstdc++-v3/testsuite/22_locale/money_get/get/char/3.cc new file mode 100644 index 000000000..507214dc9 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/money_get/get/char/3.cc @@ -0,0 +1,71 @@ +// { dg-require-namedlocale "de_DE@euro" } + +// 2001-09-12 Benjamin Kosnik + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 22.2.6.1.1 money_get members + +#include +#include +#include + +// test double version +void test03() +{ + using namespace std; + typedef istreambuf_iterator iterator_type; + + bool test __attribute__((unused)) = true; + + // basic construction + locale loc_c = locale::classic(); + locale loc_de = locale("de_DE@euro"); + VERIFY( loc_c != loc_de ); + + // total EPA budget FY 2002 + const long double digits1 = 720000000000.0; + + iterator_type end; + istringstream iss; + iss.imbue(loc_de); + // cache the money_get facet + const money_get& mon_get = use_facet >(iss.getloc()); + + iss.str("7.200.000.000,00 "); + iterator_type is_it01(iss); + long double result1; + ios_base::iostate err01 = ios_base::goodbit; + mon_get.get(is_it01, end, true, iss, err01, result1); + VERIFY( result1 == digits1 ); + VERIFY( err01 == ios_base::eofbit ); + + iss.str("7.200.000.000,00 "); + iterator_type is_it02(iss); + long double result2; + ios_base::iostate err02 = ios_base::goodbit; + mon_get.get(is_it02, end, false, iss, err02, result2); + VERIFY( result2 == digits1 ); + VERIFY( err02 == ios_base::eofbit ); +} + +int main() +{ + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/money_get/get/char/38399.cc b/libstdc++-v3/testsuite/22_locale/money_get/get/char/38399.cc new file mode 100644 index 000000000..506cc866e --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/money_get/get/char/38399.cc @@ -0,0 +1,54 @@ +// Copyright (C) 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 22.2.6.1.1 money_get members + +#include +#include +#include + +class my_moneypunct : public std::moneypunct +{ +protected: + //this should disable fraction part of monetary value + int do_frac_digits() const { return 0; } +}; + +// libstdc++/38399 +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + locale loc(locale(), new my_moneypunct()); + stringstream ss("123.455"); + ss.imbue(loc); + string digits; + ios_base::iostate err; + istreambuf_iterator iter = + use_facet >(loc).get(ss, 0, false, ss, err, digits); + + string rest = string(iter, istreambuf_iterator()); + VERIFY( digits == "123" ); + VERIFY( rest == ".455" ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/money_get/get/char/39168.cc b/libstdc++-v3/testsuite/22_locale/money_get/get/char/39168.cc new file mode 100644 index 000000000..e4d70a3e6 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/money_get/get/char/39168.cc @@ -0,0 +1,56 @@ +// Copyright (C) 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 22.2.6.1.1 money_get members + +#include +#include +#include +#include + +class my_moneypunct: public std::moneypunct +{ +protected: + std::string do_grouping() const { return std::string(1, CHAR_MAX); } +}; + +// libstdc++/39168 +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + typedef istreambuf_iterator iterator_type; + + istringstream iss; + iss.imbue(locale(iss.getloc(), new my_moneypunct)); + const money_get& mg = use_facet >(iss.getloc()); + + string digits; + ios_base::iostate err = ios_base::goodbit; + + iss.str("123,456"); + iterator_type end = mg.get(iss.rdbuf(), 0, false, iss, err, digits); + VERIFY( err == ios_base::goodbit ); + VERIFY( digits == "123" ); + VERIFY( *end == ',' ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/money_get/get/char/4.cc b/libstdc++-v3/testsuite/22_locale/money_get/get/char/4.cc new file mode 100644 index 000000000..f48cc0efb --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/money_get/get/char/4.cc @@ -0,0 +1,66 @@ +// { dg-require-namedlocale "en_HK" } + +// 2001-09-12 Benjamin Kosnik + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 22.2.6.1.1 money_get members + +#include +#include +#include + +// test double version +void test04() +{ + using namespace std; + typedef istreambuf_iterator iterator_type; + + bool test __attribute__((unused)) = true; + + // basic construction + locale loc_c = locale::classic(); + locale loc_hk = locale("en_HK"); + VERIFY( loc_c != loc_hk ); + + // input less than frac_digits + const long double digits4 = -1.0; + + iterator_type end; + istringstream iss; + iss.imbue(loc_hk); + // cache the money_get facet + const money_get& mon_get = use_facet >(iss.getloc()); + + // now try with showbase, to get currency symbol in format + iss.setf(ios_base::showbase); + + iss.str("(HKD .01)"); + iterator_type is_it03(iss); + long double result3; + ios_base::iostate err03 = ios_base::goodbit; + mon_get.get(is_it03, end, true, iss, err03, result3); + VERIFY( result3 == digits4 ); + VERIFY( err03 == ios_base::eofbit ); +} + +int main() +{ + test04(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/money_get/get/char/5.cc b/libstdc++-v3/testsuite/22_locale/money_get/get/char/5.cc new file mode 100644 index 000000000..3d0e20df3 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/money_get/get/char/5.cc @@ -0,0 +1,70 @@ +// 2001-09-12 Benjamin Kosnik + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 +// Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 22.2.6.1.1 money_get members + +#include +#include +#include + +void test05() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + // Check money_get works with other iterators besides streambuf + // input iterators. + typedef string::const_iterator iter_type; + typedef money_get mon_get_type; + const ios_base::iostate goodbit = ios_base::goodbit; + ios_base::iostate err = goodbit; + const locale loc_c = locale::classic(); + const string str = "1Eleanor Roosevelt"; + + istringstream iss; + iss.imbue(locale(loc_c, new mon_get_type)); + + // Iterator advanced, state, output. + const mon_get_type& mg = use_facet(iss.getloc()); + + // 01 string + string res1; + iter_type end1 = mg.get(str.begin(), str.end(), false, iss, err, res1); + string rem1(end1, str.end()); + VERIFY( err == goodbit ); + VERIFY( res1 == "1" ); + VERIFY( rem1 == "Eleanor Roosevelt" ); + + // 02 long double + iss.clear(); + err = goodbit; + long double res2; + iter_type end2 = mg.get(str.begin(), str.end(), false, iss, err, res2); + string rem2(end2, str.end()); + VERIFY( err == goodbit ); + VERIFY( res2 == 1 ); + VERIFY( rem2 == "Eleanor Roosevelt" ); +} + +int main() +{ + test05(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/money_get/get/char/6.cc b/libstdc++-v3/testsuite/22_locale/money_get/get/char/6.cc new file mode 100644 index 000000000..1afe04646 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/money_get/get/char/6.cc @@ -0,0 +1,97 @@ +// 2001-09-12 Benjamin Kosnik + +// Copyright (C) 2001, 2002, 2003, 2004, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 22.2.6.1.1 money_get members + +#include +#include +#include + +struct My_money_io : public std::moneypunct +{ + char_type do_decimal_point() const { return '.'; } + std::string do_grouping() const { return "\004"; } + + std::string do_curr_symbol() const { return "$"; } + std::string do_positive_sign() const { return ""; } + std::string do_negative_sign() const { return "-"; } + + int do_frac_digits() const { return 2; } + + pattern do_neg_format() const + { + pattern pat = { { symbol, none, sign, value } }; + return pat; + } +}; + +// libstdc++/5579 +void test06() +{ + using namespace std; + typedef istreambuf_iterator InIt; + + bool test __attribute__((unused)) = true; + + locale loc(locale::classic(), new My_money_io); + + string bufferp("$1234.56"); + string buffern("$-1234.56"); + string bufferp_ns("1234.56"); + string buffern_ns("-1234.56"); + + bool intl = false; + + InIt iendp, iendn, iendp_ns, iendn_ns; + ios_base::iostate err; + string valp, valn, valp_ns, valn_ns; + + const money_get& mg = + use_facet >(loc); + + istringstream fmtp(bufferp); + fmtp.imbue(loc); + InIt ibegp(fmtp); + mg.get(ibegp,iendp,intl,fmtp,err,valp); + VERIFY( valp == "123456" ); + + istringstream fmtn(buffern); + fmtn.imbue(loc); + InIt ibegn(fmtn); + mg.get(ibegn,iendn,intl,fmtn,err,valn); + VERIFY( valn == "-123456" ); + + istringstream fmtp_ns(bufferp_ns); + fmtp_ns.imbue(loc); + InIt ibegp_ns(fmtp_ns); + mg.get(ibegp_ns,iendp_ns,intl,fmtp_ns,err,valp_ns); + VERIFY( valp_ns == "123456" ); + + istringstream fmtn_ns(buffern_ns); + fmtn_ns.imbue(loc); + InIt ibegn_ns(fmtn_ns); + mg.get(ibegn_ns,iendn_ns,intl,fmtn_ns,err,valn_ns); + VERIFY( valn_ns == "-123456" ); +} + +int main() +{ + test06(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/money_get/get/char/7.cc b/libstdc++-v3/testsuite/22_locale/money_get/get/char/7.cc new file mode 100644 index 000000000..c5f9ae2d2 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/money_get/get/char/7.cc @@ -0,0 +1,72 @@ +// 2001-09-12 Benjamin Kosnik + +// Copyright (C) 2001, 2002, 2003, 2004, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 22.2.6.1.1 money_get members + +#include +#include +#include + +// 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 test07() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef istreambuf_iterator InIt; + InIt iend1, iend2, iend3; + + locale loc_c = locale::classic(); + string buffer1("123"); + string buffer2("456"); + string buffer3("Golgafrincham"); // From Nathan's original idea. + + string val; + + ios_base::iostate err; + + const money_get& mg = use_facet >(loc_c); + + istringstream fmt1(buffer1); + fmt1.imbue(loc_c); + InIt ibeg1(fmt1); + mg.get(ibeg1, iend1, false, fmt1, err, val); + VERIFY( val == buffer1 ); + + istringstream fmt2(buffer2); + fmt2.imbue(loc_c); + InIt ibeg2(fmt2); + mg.get(ibeg2, iend2, false, fmt2, err, val); + VERIFY( val == buffer2 ); + + val = buffer3; + istringstream fmt3(buffer3); + fmt3.imbue(loc_c); + InIt ibeg3(fmt3); + mg.get(ibeg3, iend3, false, fmt3, err, val); + VERIFY( val == buffer3 ); +} + +int main() +{ + test07(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/money_get/get/char/8.cc b/libstdc++-v3/testsuite/22_locale/money_get/get/char/8.cc new file mode 100644 index 000000000..c0c45954a --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/money_get/get/char/8.cc @@ -0,0 +1,122 @@ +// 2001-09-12 Benjamin Kosnik + +// Copyright (C) 2001, 2002, 2003, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 22.2.6.1.1 money_get members + +#include +#include +#include + +struct My_money_io_a : public std::moneypunct +{ + char_type do_decimal_point() const { return '.'; } + std::string do_grouping() const { return "\004"; } + + std::string do_curr_symbol() const { return "$"; } + std::string do_positive_sign() const { return "()"; } + + int do_frac_digits() const { return 2; } + + pattern do_neg_format() const + { + pattern pat = { { sign, value, space, symbol } }; + return pat; + } +}; + +struct My_money_io_b : public std::moneypunct +{ + char_type do_decimal_point() const { return '.'; } + std::string do_grouping() const { return "\004"; } + + std::string do_curr_symbol() const { return "$"; } + std::string do_positive_sign() const { return "()"; } + + int do_frac_digits() const { return 2; } + + pattern do_neg_format() const + { + pattern pat = { { sign, value, symbol, none } }; + return pat; + } +}; + +// This one exercises patterns of the type { X, Y, Z, symbol } and +// { X, Y, symbol, none } for a two character long sign. Therefore +// the optional symbol (showbase is false by default) must be consumed +// if present, since "rest of the sign" is left to read. +void test08() +{ + using namespace std; + typedef istreambuf_iterator InIt; + + bool intl = false; + bool test __attribute__((unused)) = true; + ios_base::iostate err; + + locale loc_a(locale::classic(), new My_money_io_a); + + string buffer_a("(1234.56 $)"); + string buffer_a_ns("(1234.56 )"); + + InIt iend_a, iend_a_ns; + string val_a, val_a_ns; + + const money_get& mg_a = use_facet >(loc_a); + + istringstream fmt_a(buffer_a); + fmt_a.imbue(loc_a); + InIt ibeg_a(fmt_a); + mg_a.get(ibeg_a,iend_a,intl,fmt_a,err,val_a); + VERIFY( val_a == "123456" ); + + istringstream fmt_a_ns(buffer_a_ns); + fmt_a_ns.imbue(loc_a); + InIt ibeg_a_ns(fmt_a_ns); + mg_a.get(ibeg_a_ns,iend_a_ns,intl,fmt_a_ns,err,val_a_ns); + VERIFY( val_a_ns == "123456" ); + + locale loc_b(locale::classic(), new My_money_io_b); + + string buffer_b("(1234.56$)"); + string buffer_b_ns("(1234.56)"); + + InIt iend_b, iend_b_ns; + string val_b, val_b_ns; + + const money_get& mg_b = use_facet >(loc_b); + + istringstream fmt_b(buffer_b); + fmt_b.imbue(loc_b); + InIt ibeg_b(fmt_b); + mg_b.get(ibeg_b,iend_b,intl,fmt_b,err,val_b); + VERIFY( val_b == "123456" ); + + istringstream fmt_b_ns(buffer_b_ns); + fmt_b_ns.imbue(loc_b); + InIt ibeg_b_ns(fmt_b_ns); + mg_b.get(ibeg_b_ns,iend_b_ns,intl,fmt_b_ns,err,val_b_ns); + VERIFY( val_b_ns == "123456" ); +} + +int main() +{ + test08(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/money_get/get/char/9.cc b/libstdc++-v3/testsuite/22_locale/money_get/get/char/9.cc new file mode 100644 index 000000000..00bf88371 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/money_get/get/char/9.cc @@ -0,0 +1,90 @@ +// 2003-05-27 Brendan Kehoe + +// Copyright (C) 2003, 2004, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// $22.2.6.3/3 +// The number of digits required after the decimal point (if any) is exactly +// the value returned by frac_digits(). + +#include +#include + +class dublin : public std::moneypunct { +public: + int do_frac_digits() const { return 3; } +}; + +int main() +{ + std::istringstream liffey; + std::string coins; + + std::locale eire(std::locale::classic(), new dublin); + liffey.imbue(eire); + + const std::money_get& greed + = std::use_facet >(liffey.getloc()); + + typedef std::istreambuf_iterator iterator_type; + iterator_type is(liffey); + iterator_type end; + + std::ios_base::iostate err01 = std::ios_base::goodbit; + + int fails = 0; + + // Feed it 1 digit too many, which should fail. + liffey.str("12.3456"); + greed.get(is, end, false, liffey, err01, coins); + if (! (err01 & std::ios_base::failbit )) + fails |= 0x01; + + err01 = std::ios_base::goodbit; + + // Feed it exactly what it wants, which should succeed. + liffey.str("12.345"); + greed.get(is, end, false, liffey, err01, coins); + if ( err01 & std::ios_base::failbit ) + fails |= 0x02; + + err01 = std::ios_base::goodbit; + + // Feed it 1 digit too few, which should fail. + liffey.str("12.34"); + greed.get(is, end, false, liffey, err01, coins); + if (! ( err01 & std::ios_base::failbit )) + fails |= 0x04; + + err01 = std::ios_base::goodbit; + + // Feed it only a decimal-point, which should fail. + liffey.str("12."); + greed.get(is, end, false, liffey, err01, coins); + if (! (err01 & std::ios_base::failbit )) + fails |= 0x08; + + err01 = std::ios_base::goodbit; + + // Feed it no decimal-point at all, which should succeed. + liffey.str("12"); + greed.get(is, end, false, liffey, err01, coins); + if ( err01 & std::ios_base::failbit ) + fails |= 0x10; + + return fails; +} diff --git a/libstdc++-v3/testsuite/22_locale/money_get/get/char/wrapped_env.cc b/libstdc++-v3/testsuite/22_locale/money_get/get/char/wrapped_env.cc new file mode 100644 index 000000000..c0a769d78 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/money_get/get/char/wrapped_env.cc @@ -0,0 +1,74 @@ +// { dg-require-namedlocale "de_DE" } +// { dg-require-namedlocale "de_DE@euro" } +// { dg-require-namedlocale "en_HK" } + +// 2001-08-15 Benjamin Kosnik + +// Copyright (C) 2001, 2002, 2003, 2005, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 22.2.4.1.1 collate members + +#include + +#define main discard_main_1 +#include "1.cc" +#undef main + +#define main discard_main_2 +#include "2.cc" +#undef main + +#define main discard_main_3 +#include "3.cc" +#undef main + +#define main discard_main_4 +#include "4.cc" +#undef main + +#define main discard_main_5 +#include "5.cc" +#undef main + +#define main discard_main_6 +#include "6.cc" +#undef main + +#define main discard_main_7 +#include "7.cc" +#undef main + +#define main discard_main_8 +#include "8.cc" +#undef main + +int main() +{ + using namespace __gnu_test; + func_callback two; + two.push_back(&test01); + two.push_back(&test02); + two.push_back(&test03); + two.push_back(&test04); + two.push_back(&test05); + two.push_back(&test06); + two.push_back(&test07); + two.push_back(&test08); + run_tests_wrapped_env("de_DE", "LANG", two); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/money_get/get/char/wrapped_locale.cc b/libstdc++-v3/testsuite/22_locale/money_get/get/char/wrapped_locale.cc new file mode 100644 index 000000000..795271f3f --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/money_get/get/char/wrapped_locale.cc @@ -0,0 +1,74 @@ +// { dg-require-namedlocale "ja_JP.eucjp" } +// { dg-require-namedlocale "de_DE@euro" } +// { dg-require-namedlocale "en_HK" } + +// 2001-08-15 Benjamin Kosnik + +// Copyright (C) 2001, 2002, 2003, 2005, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 22.2.4.1.1 collate members + +#include + +#define main discard_main_1 +#include "1.cc" +#undef main + +#define main discard_main_2 +#include "2.cc" +#undef main + +#define main discard_main_3 +#include "3.cc" +#undef main + +#define main discard_main_4 +#include "4.cc" +#undef main + +#define main discard_main_5 +#include "5.cc" +#undef main + +#define main discard_main_6 +#include "6.cc" +#undef main + +#define main discard_main_7 +#include "7.cc" +#undef main + +#define main discard_main_8 +#include "8.cc" +#undef main + +int main() +{ + using namespace __gnu_test; + func_callback two; + two.push_back(&test01); + two.push_back(&test02); + two.push_back(&test03); + two.push_back(&test04); + two.push_back(&test05); + two.push_back(&test06); + two.push_back(&test07); + two.push_back(&test08); + run_tests_wrapped_locale("ja_JP.eucjp", two); + return 0; +} -- cgit v1.2.3