diff options
Diffstat (limited to 'libstdc++-v3/testsuite/22_locale/time_get')
86 files changed, 5874 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/22_locale/time_get/date_order/char/1.cc b/libstdc++-v3/testsuite/22_locale/time_get/date_order/char/1.cc new file mode 100644 index 000000000..8265f2f65 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/date_order/char/1.cc @@ -0,0 +1,55 @@ +// 2001-09-21 Benjamin Kosnik <bkoz@redhat.com> + +// 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + typedef time_base::dateorder dateorder; + typedef istreambuf_iterator<char> iterator_type; + + // basic construction + locale loc_c = locale::classic(); + + const string empty; + + // create an ostream-derived object, cache the time_get facet + iterator_type end; + istringstream iss; + iss.imbue(loc_c); + const time_get<char>& tim_get = use_facet<time_get<char> >(iss.getloc()); + + // 1 + // dateorder date_order() const + dateorder do1 = tim_get.date_order(); + // VERIFY( do1 == time_base::mdy ); + VERIFY( do1 == time_base::no_order ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/date_order/char/wrapped_env.cc b/libstdc++-v3/testsuite/22_locale/time_get/date_order/char/wrapped_env.cc new file mode 100644 index 000000000..f8f6daa9e --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/date_order/char/wrapped_env.cc @@ -0,0 +1,37 @@ +// { dg-require-namedlocale "de_DE" } + +// 2001-08-15 Benjamin Kosnik <bkoz@redhat.com> + +// 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.4.1.1 collate members + +#include <testsuite_hooks.h> + +#define main discard_main_1 +#include "1.cc" +#undef main + +int main() +{ + using namespace __gnu_test; + func_callback two; + two.push_back(&test01); + run_tests_wrapped_env("de_DE", "LANG", two); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/date_order/char/wrapped_locale.cc b/libstdc++-v3/testsuite/22_locale/time_get/date_order/char/wrapped_locale.cc new file mode 100644 index 000000000..ac0fccc32 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/date_order/char/wrapped_locale.cc @@ -0,0 +1,37 @@ +// { dg-require-namedlocale "ja_JP.eucjp" } + +// 2001-08-15 Benjamin Kosnik <bkoz@redhat.com> + +// 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.4.1.1 collate members + +#include <testsuite_hooks.h> + +#define main discard_main_1 +#include "1.cc" +#undef main + +int main() +{ + using namespace __gnu_test; + func_callback two; + two.push_back(&test01); + run_tests_wrapped_locale("ja_JP.eucjp", two); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/date_order/wchar_t/1.cc b/libstdc++-v3/testsuite/22_locale/time_get/date_order/wchar_t/1.cc new file mode 100644 index 000000000..f5d850d81 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/date_order/wchar_t/1.cc @@ -0,0 +1,56 @@ +// 2001-09-21 Benjamin Kosnik <bkoz@redhat.com> + +// 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + typedef time_base::dateorder dateorder; + typedef istreambuf_iterator<wchar_t> iterator_type; + + // basic construction + locale loc_c = locale::classic(); + + const string empty; + + // create an ostream-derived object, cache the time_get facet + iterator_type end; + istringstream iss; + iss.imbue(loc_c); + const time_get<wchar_t>& tim_get = use_facet<time_get<wchar_t> >(iss.getloc()); + + // 1 + // dateorder date_order() const + iss.imbue(loc_c); + dateorder do1 = tim_get.date_order(); + // VERIFY( do1 == time_base::mdy ); + VERIFY( do1 == time_base::no_order ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/date_order/wchar_t/wrapped_env.cc b/libstdc++-v3/testsuite/22_locale/time_get/date_order/wchar_t/wrapped_env.cc new file mode 100644 index 000000000..f8f6daa9e --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/date_order/wchar_t/wrapped_env.cc @@ -0,0 +1,37 @@ +// { dg-require-namedlocale "de_DE" } + +// 2001-08-15 Benjamin Kosnik <bkoz@redhat.com> + +// 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.4.1.1 collate members + +#include <testsuite_hooks.h> + +#define main discard_main_1 +#include "1.cc" +#undef main + +int main() +{ + using namespace __gnu_test; + func_callback two; + two.push_back(&test01); + run_tests_wrapped_env("de_DE", "LANG", two); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/date_order/wchar_t/wrapped_locale.cc b/libstdc++-v3/testsuite/22_locale/time_get/date_order/wchar_t/wrapped_locale.cc new file mode 100644 index 000000000..ac0fccc32 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/date_order/wchar_t/wrapped_locale.cc @@ -0,0 +1,37 @@ +// { dg-require-namedlocale "ja_JP.eucjp" } + +// 2001-08-15 Benjamin Kosnik <bkoz@redhat.com> + +// 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.4.1.1 collate members + +#include <testsuite_hooks.h> + +#define main discard_main_1 +#include "1.cc" +#undef main + +int main() +{ + using namespace __gnu_test; + func_callback two; + two.push_back(&test01); + run_tests_wrapped_locale("ja_JP.eucjp", two); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_date/char/1.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_date/char/1.cc new file mode 100644 index 000000000..1a8f9a940 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_date/char/1.cc @@ -0,0 +1,96 @@ +// 2001-09-21 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef istreambuf_iterator<char> iterator_type; + + // basic construction + locale loc_c = locale::classic(); + + const string empty; + + // create an ostream-derived object, cache the time_get facet + iterator_type end; + + istringstream iss; + iss.imbue(loc_c); + const time_get<char>& tim_get = use_facet<time_get<char> >(iss.getloc()); + + const ios_base::iostate good = ios_base::goodbit; + ios_base::iostate errorstate = good; + + // create "C" time objects + const tm time_bday = __gnu_test::test_tm(0, 0, 12, 4, 3, 71, 0, 93, 0); + + // iter_type + // get_date(iter_type, iter_type, ios_base&, ios_base::iostate&, tm*) const + + // sanity checks for "C" locale + iss.str("04/04/71"); + iterator_type is_it01(iss); + tm time01; + errorstate = good; + tim_get.get_date(is_it01, end, iss, errorstate, &time01); + VERIFY( time01.tm_year == time_bday.tm_year ); + VERIFY( time01.tm_mon == time_bday.tm_mon ); + VERIFY( time01.tm_mday == time_bday.tm_mday ); + VERIFY( errorstate == ios_base::eofbit ); + + iss.str("04/04/71 "); + iterator_type is_it02(iss); + tm time02; + errorstate = good; + iterator_type ret02 = tim_get.get_date(is_it02, end, iss, errorstate, + &time02); + VERIFY( time02.tm_year == time_bday.tm_year ); + VERIFY( time02.tm_mon == time_bday.tm_mon ); + VERIFY( time02.tm_mday == time_bday.tm_mday ); + VERIFY( errorstate == good ); + VERIFY( *ret02 == ' ' ); + + iss.str("04/04d/71 "); + iterator_type is_it03(iss); + tm time03; + time03.tm_year = 3; + errorstate = good; + iterator_type ret03 = tim_get.get_date(is_it03, end, iss, errorstate, + &time03); + VERIFY( time03.tm_year == 3 ); + VERIFY( time03.tm_mon == time_bday.tm_mon ); + VERIFY( time03.tm_mday == time_bday.tm_mday ); + VERIFY( errorstate == ios_base::failbit ); + VERIFY( *ret03 == 'd' ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_date/char/12750.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_date/char/12750.cc new file mode 100644 index 000000000..191c11b16 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_date/char/12750.cc @@ -0,0 +1,80 @@ +// { dg-require-namedlocale "is_IS" } + +// 2003-10-27 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2003, 2004, 2005, 2006, 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +// libstdc++/12750 +void test01() +{ + using namespace std; + typedef istreambuf_iterator<char> iterator_type; + + bool test __attribute__((unused)) = true; + + // basic construction + locale loc_is = locale("is_IS"); + + // create an ostream-derived object, cache the time_get facet + iterator_type end; + + istringstream iss; + const time_get<char>& tim_get = use_facet<time_get<char> >(iss.getloc()); + + const ios_base::iostate good = ios_base::goodbit; + ios_base::iostate errorstate = good; + + // create "C" time objects + const tm time_bday01 = __gnu_test::test_tm(0, 0, 12, 2, 9, 103, 4, 274, -1); + const tm time_bday02 = __gnu_test::test_tm(0, 0, 12, 26, 9, 103, 0, 298, -1); + + // inspection of named locales, is_IS + iss.imbue(loc_is); + + iss.str("Fim 2.Okt 2003"); + iterator_type is_it01(iss); + tm time01; + errorstate = good; + tim_get.get_date(is_it01, end, iss, errorstate, &time01); + VERIFY( time01.tm_mon == time_bday01.tm_mon ); + VERIFY( time01.tm_mday == time_bday01.tm_mday ); + VERIFY( time01.tm_year == time_bday01.tm_year ); + VERIFY( errorstate == ios_base::eofbit ); + + iss.str("Sun 26.Okt 2003"); + iterator_type is_it02(iss); + tm time02; + errorstate = good; + tim_get.get_date(is_it02, end, iss, errorstate, &time02); + VERIFY( time02.tm_mon == time_bday02.tm_mon ); + VERIFY( time02.tm_mday == time_bday02.tm_mday ); + VERIFY( time02.tm_year == time_bday02.tm_year ); + VERIFY( errorstate == ios_base::eofbit ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_date/char/12791.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_date/char/12791.cc new file mode 100644 index 000000000..a8c79454a --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_date/char/12791.cc @@ -0,0 +1,66 @@ +// 2003-12-03 Paolo Carlini <pcarlini@suse.de> + +// 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +// libstdc++/12791 +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef istreambuf_iterator<char> iterator_type; + + // create an ostream-derived object, cache the time_get facet + iterator_type end; + + istringstream iss; + const time_get<char>& tim_get = use_facet<time_get<char> >(iss.getloc()); + + const ios_base::iostate good = ios_base::goodbit; + ios_base::iostate errorstate = good; + + iss.str("60/04/71"); + iterator_type is_it01(iss); + tm time01; + errorstate = good; + iterator_type ret01 = tim_get.get_date(is_it01, end, iss, errorstate, + &time01); + VERIFY( errorstate == ios_base::failbit ); + VERIFY( *ret01 == '6' ); + + iss.str("04/38/71"); + iterator_type is_it02(iss); + tm time02; + errorstate = good; + iterator_type ret02 = tim_get.get_date(is_it02, end, iss, errorstate, + &time02); + VERIFY( errorstate == ios_base::failbit ); + VERIFY( *ret02 == '8' ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_date/char/2.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_date/char/2.cc new file mode 100644 index 000000000..d0e5ca490 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_date/char/2.cc @@ -0,0 +1,96 @@ +// { dg-require-namedlocale "en_HK" } +// { dg-require-namedlocale "de_DE" } + +// 2001-09-21 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +void test02() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef istreambuf_iterator<char> iterator_type; + + // basic construction and sanity checks. + locale loc_c = locale::classic(); + locale loc_hk = locale("en_HK"); + locale loc_de = locale("de_DE"); + VERIFY( loc_hk != loc_c ); + VERIFY( loc_hk != loc_de ); + + const string empty; + + // create an ostream-derived object, cache the time_get facet + iterator_type end; + + istringstream iss; + const time_get<char>& tim_get = use_facet<time_get<char> >(iss.getloc()); + + const ios_base::iostate good = ios_base::goodbit; + ios_base::iostate errorstate = good; + + // create "C" time objects + const tm time_bday = __gnu_test::test_tm(0, 0, 12, 4, 3, 71, 0, 93, 0); + + // iter_type + // get_date(iter_type, iter_type, ios_base&, ios_base::iostate&, tm*) const + + // sanity checks for "C" locale + iss.imbue(loc_c); + iss.str("04/04/71"); + iterator_type is_it01(iss); + errorstate = good; + + // inspection of named locales, de_DE + iss.imbue(loc_de); + iss.str("04.04.1971"); + iterator_type is_it10(iss); + tm time10; + errorstate = good; + tim_get.get_date(is_it10, end, iss, errorstate, &time10); + VERIFY( time10.tm_mon == time_bday.tm_mon ); + VERIFY( time10.tm_mday == time_bday.tm_mday ); + VERIFY( time10.tm_year == time_bday.tm_year ); + VERIFY( errorstate == ios_base::eofbit ); + + // inspection of named locales, en_HK + iss.imbue(loc_hk); + iss.str("Sunday, April 04, 1971"); + iterator_type is_it20(iss); + tm time20; + errorstate = good; + tim_get.get_date(is_it20, end, iss, errorstate, &time20); + VERIFY( time20.tm_mon == time_bday.tm_mon ); + VERIFY( time20.tm_mday == time_bday.tm_mday ); + VERIFY( time20.tm_year == time_bday.tm_year ); + VERIFY( errorstate == ios_base::eofbit ); +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_date/char/26701.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_date/char/26701.cc new file mode 100644 index 000000000..5fbf074a4 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_date/char/26701.cc @@ -0,0 +1,64 @@ +// { dg-require-namedlocale "en_GB" } + +// 2010-01-06 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +// libstdc++/26701 +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef istreambuf_iterator<char> iterator_type; + + locale loc_en = locale("en_GB"); + + tm tm0 = __gnu_test::test_tm(0, 0, 0, 0, 0, 0, 0, 0, 0); + + iterator_type end; + + istringstream iss; + iss.imbue(loc_en); + const time_get<char>& tg = use_facet<time_get<char> >(iss.getloc()); + + const ios_base::iostate good = ios_base::goodbit; + ios_base::iostate errorstate = good; + + iss.str("01/02/2003"); + iterator_type is_it0(iss); + + errorstate = good; + tg.get_date(is_it0, end, iss, errorstate, &tm0); + VERIFY( errorstate == ios_base::eofbit ); + VERIFY( tm0.tm_year + 1900 == 2003 ); + VERIFY( tm0.tm_mon + 1 == 2 ); + VERIFY( tm0.tm_mday == 1 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_date/char/3.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_date/char/3.cc new file mode 100644 index 000000000..4bc939d2a --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_date/char/3.cc @@ -0,0 +1,71 @@ +// 2001-09-21 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +void test03() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + // Check time_get works with other iterators besides streambuf + // input iterators. + typedef string::const_iterator iter_type; + typedef time_get<char, iter_type> time_get_type; + const ios_base::iostate goodbit = ios_base::goodbit; + ios_base::iostate err = goodbit; + const locale loc_c = locale::classic(); + + // Create "C" time objects + const tm time_sanity = __gnu_test::test_tm(0, 0, 12, 26, 5, 97, 2, 0, 0); + tm tm1; + + istringstream iss; + iss.imbue(locale(loc_c, new time_get_type)); + + // Iterator advanced, state, output. + const time_get_type& tg = use_facet<time_get_type>(iss.getloc()); + + // Cindy Sherman's Untitled Film Stills + // June 26-September 2, 1997 + const string str = "06/26/97 Tuesday September 1997 Cindy Sherman"; + + // 02 get_date + string res2; + err = goodbit; + // White space is not eaten, so manually increment past it. + iter_type end2 = tg.get_date(str.begin(), str.end(), iss, err, &tm1); + string rem2(end2, str.end()); + VERIFY( err == goodbit ); + VERIFY( tm1.tm_year == time_sanity.tm_year ); + VERIFY( tm1.tm_mon == time_sanity.tm_mon ); + VERIFY( tm1.tm_mday == time_sanity.tm_mday ); + VERIFY( rem2 == " Tuesday September 1997 Cindy Sherman" ); +} + +int main() +{ + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_date/char/5.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_date/char/5.cc new file mode 100644 index 000000000..f08cd6f07 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_date/char/5.cc @@ -0,0 +1,70 @@ +// 2006-06-16 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2006, 2009, 2010 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +// Check that the err argument is ignored by get_date. +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef string::const_iterator iter_type; + typedef time_get<char, iter_type> time_get_type; + const ios_base::iostate goodbit = ios_base::goodbit; + const ios_base::iostate eofbit = ios_base::eofbit; + const ios_base::iostate failbit = ios_base::failbit; + ios_base::iostate err = goodbit; + const locale loc_c = locale::classic(); + + // Create "C" time objects + const tm time_sanity = __gnu_test::test_tm(0, 0, 12, 26, 5, 97, 2, 0, 0); + tm tm0 = __gnu_test::test_tm(0, 0, 0, 0, 0, 0, 0, 0, 0); + tm tm1 = __gnu_test::test_tm(0, 0, 0, 0, 0, 0, 0, 0, 0); + + istringstream iss; + iss.imbue(locale(loc_c, new time_get_type)); + + const time_get_type& tg = use_facet<time_get_type>(iss.getloc()); + + const string str0 = "1"; + tg.get_date(str0.begin(), str0.end(), iss, err, &tm0); + VERIFY( err == (failbit | eofbit) ); + VERIFY( tm0.tm_year == 0 ); + VERIFY( tm0.tm_mon == 0 ); + VERIFY( tm0.tm_mday == 0 ); + + const string str1 = "06/26/97 "; + iter_type end1 = tg.get_date(str1.begin(), str1.end(), iss, err, &tm1); + VERIFY( err == (failbit | eofbit) ); + VERIFY( tm1.tm_year == time_sanity.tm_year ); + VERIFY( tm1.tm_mon == time_sanity.tm_mon ); + VERIFY( tm1.tm_mday == time_sanity.tm_mday ); + VERIFY( *end1 == ' ' ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_date/char/wrapped_env.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_date/char/wrapped_env.cc new file mode 100644 index 000000000..8f116717b --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_date/char/wrapped_env.cc @@ -0,0 +1,48 @@ +// { dg-require-namedlocale "de_DE" } +// { dg-require-namedlocale "en_HK" } + +// 2001-08-15 Benjamin Kosnik <bkoz@redhat.com> + +// 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.4.1.1 collate members + +#include <testsuite_hooks.h> + +#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 + +int main() +{ + using namespace __gnu_test; + func_callback two; + two.push_back(&test01); + two.push_back(&test02); + two.push_back(&test03); + run_tests_wrapped_env("de_DE", "LANG", two); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_date/char/wrapped_locale.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_date/char/wrapped_locale.cc new file mode 100644 index 000000000..a4edc45a8 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_date/char/wrapped_locale.cc @@ -0,0 +1,49 @@ +// { dg-require-namedlocale "ja_JP.eucjp" } +// { dg-require-namedlocale "de_DE" } +// { dg-require-namedlocale "en_HK" } + +// 2001-08-15 Benjamin Kosnik <bkoz@redhat.com> + +// 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.4.1.1 collate members + +#include <testsuite_hooks.h> + +#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 + +int main() +{ + using namespace __gnu_test; + func_callback two; + two.push_back(&test01); + two.push_back(&test02); + two.push_back(&test03); + run_tests_wrapped_locale("ja_JP.eucjp", two); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_date/wchar_t/1.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_date/wchar_t/1.cc new file mode 100644 index 000000000..ce2c8bcab --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_date/wchar_t/1.cc @@ -0,0 +1,97 @@ +// 2001-09-21 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef istreambuf_iterator<wchar_t> iterator_type; + + // basic construction + locale loc_c = locale::classic(); + + const wstring empty; + + // create an ostream-derived object, cache the time_get facet + iterator_type end; + + wistringstream iss; + iss.imbue(loc_c); + const time_get<wchar_t>& tim_get = + use_facet<time_get<wchar_t> >(iss.getloc()); + + const ios_base::iostate good = ios_base::goodbit; + ios_base::iostate errorstate = good; + + // create "C" time objects + const tm time_bday = __gnu_test::test_tm(0, 0, 12, 4, 3, 71, 0, 93, 0); + + // iter_type + // get_date(iter_type, iter_type, ios_base&, ios_base::iostate&, tm*) const + + // sanity checks for "C" locale + iss.str(L"04/04/71"); + iterator_type is_it01(iss); + tm time01; + errorstate = good; + tim_get.get_date(is_it01, end, iss, errorstate, &time01); + VERIFY( time01.tm_year == time_bday.tm_year ); + VERIFY( time01.tm_mon == time_bday.tm_mon ); + VERIFY( time01.tm_mday == time_bday.tm_mday ); + VERIFY( errorstate == ios_base::eofbit ); + + iss.str(L"04/04/71 "); + iterator_type is_it02(iss); + tm time02; + errorstate = good; + iterator_type ret02 = tim_get.get_date(is_it02, end, iss, errorstate, + &time02); + VERIFY( time02.tm_year == time_bday.tm_year ); + VERIFY( time02.tm_mon == time_bday.tm_mon ); + VERIFY( time02.tm_mday == time_bday.tm_mday ); + VERIFY( errorstate == good ); + VERIFY( *ret02 == L' ' ); + + iss.str(L"04/04d/71 "); + iterator_type is_it03(iss); + tm time03; + time03.tm_year = 3; + errorstate = good; + iterator_type ret03 = tim_get.get_date(is_it03, end, iss, errorstate, + &time03); + VERIFY( time03.tm_year == 3 ); + VERIFY( time03.tm_mon == time_bday.tm_mon ); + VERIFY( time03.tm_mday == time_bday.tm_mday ); + VERIFY( errorstate == ios_base::failbit ); + VERIFY( *ret03 == L'd' ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_date/wchar_t/12750.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_date/wchar_t/12750.cc new file mode 100644 index 000000000..74d637f58 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_date/wchar_t/12750.cc @@ -0,0 +1,80 @@ +// { dg-require-namedlocale "is_IS" } + +// 2003-10-27 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2003, 2004, 2005, 2006, 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +// libstdc++/12750 +void test01() +{ + using namespace std; + typedef istreambuf_iterator<wchar_t> iterator_type; + + bool test __attribute__((unused)) = true; + + // basic construction + locale loc_is = locale("is_IS"); + + // create an ostream-derived object, cache the time_get facet + iterator_type end; + + wistringstream iss; + const time_get<wchar_t>& tim_get = use_facet<time_get<wchar_t> >(iss.getloc()); + + const ios_base::iostate good = ios_base::goodbit; + ios_base::iostate errorstate = good; + + // create "C" time objects + const tm time_bday01 = __gnu_test::test_tm(0, 0, 12, 2, 9, 103, 4, 274, -1); + const tm time_bday02 = __gnu_test::test_tm(0, 0, 12, 26, 9, 103, 0, 298, -1); + + // inspection of named locales, is_IS + iss.imbue(loc_is); + + iss.str(L"Fim 2.Okt 2003"); + iterator_type is_it01(iss); + tm time01; + errorstate = good; + tim_get.get_date(is_it01, end, iss, errorstate, &time01); + VERIFY( time01.tm_mon == time_bday01.tm_mon ); + VERIFY( time01.tm_mday == time_bday01.tm_mday ); + VERIFY( time01.tm_year == time_bday01.tm_year ); + VERIFY( errorstate == ios_base::eofbit ); + + iss.str(L"Sun 26.Okt 2003"); + iterator_type is_it02(iss); + tm time02; + errorstate = good; + tim_get.get_date(is_it02, end, iss, errorstate, &time02); + VERIFY( time02.tm_mon == time_bday02.tm_mon ); + VERIFY( time02.tm_mday == time_bday02.tm_mday ); + VERIFY( time02.tm_year == time_bday02.tm_year ); + VERIFY( errorstate == ios_base::eofbit ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_date/wchar_t/12791.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_date/wchar_t/12791.cc new file mode 100644 index 000000000..cf279fda2 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_date/wchar_t/12791.cc @@ -0,0 +1,67 @@ +// 2003-12-03 Paolo Carlini <pcarlini@suse.de> + +// 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +// libstdc++/12791 +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef istreambuf_iterator<wchar_t> iterator_type; + + // create an ostream-derived object, cache the time_get facet + iterator_type end; + + wistringstream iss; + const time_get<wchar_t>& tim_get = + use_facet<time_get<wchar_t> >(iss.getloc()); + + const ios_base::iostate good = ios_base::goodbit; + ios_base::iostate errorstate = good; + + iss.str(L"60/04/71"); + iterator_type is_it01(iss); + tm time01; + errorstate = good; + iterator_type ret01 = tim_get.get_date(is_it01, end, iss, errorstate, + &time01); + VERIFY( errorstate == ios_base::failbit ); + VERIFY( *ret01 == L'6' ); + + iss.str(L"04/38/71"); + iterator_type is_it02(iss); + tm time02; + errorstate = good; + iterator_type ret02 = tim_get.get_date(is_it02, end, iss, errorstate, + &time02); + VERIFY( errorstate == ios_base::failbit ); + VERIFY( *ret02 == L'8' ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_date/wchar_t/2.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_date/wchar_t/2.cc new file mode 100644 index 000000000..bb6d72b08 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_date/wchar_t/2.cc @@ -0,0 +1,96 @@ +// { dg-require-namedlocale "en_HK" } +// { dg-require-namedlocale "de_DE" } + +// 2001-09-21 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +void test02() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef istreambuf_iterator<wchar_t> iterator_type; + + // basic construction and sanity checks. + locale loc_c = locale::classic(); + locale loc_hk = locale("en_HK"); + locale loc_de = locale("de_DE"); + VERIFY( loc_hk != loc_c ); + VERIFY( loc_hk != loc_de ); + + const wstring empty; + + // create an ostream-derived object, cache the time_get facet + iterator_type end; + + wistringstream iss; + const time_get<wchar_t>& tim_get = use_facet<time_get<wchar_t> >(iss.getloc()); + + const ios_base::iostate good = ios_base::goodbit; + ios_base::iostate errorstate = good; + + // create "C" time objects + const tm time_bday = __gnu_test::test_tm(0, 0, 12, 4, 3, 71, 0, 93, 0); + + // iter_type + // get_date(iter_type, iter_type, ios_base&, ios_base::iostate&, tm*) const + + // sanity checks for "C" locale + iss.imbue(loc_c); + iss.str(L"04/04/71"); + iterator_type is_it01(iss); + errorstate = good; + + // inspection of named locales, de_DE + iss.imbue(loc_de); + iss.str(L"04.04.1971"); + iterator_type is_it10(iss); + tm time10; + errorstate = good; + tim_get.get_date(is_it10, end, iss, errorstate, &time10); + VERIFY( time10.tm_mon == time_bday.tm_mon ); + VERIFY( time10.tm_mday == time_bday.tm_mday ); + VERIFY( time10.tm_year == time_bday.tm_year ); + VERIFY( errorstate == ios_base::eofbit ); + + // inspection of named locales, en_HK + iss.imbue(loc_hk); + iss.str(L"Sunday, April 04, 1971"); + iterator_type is_it20(iss); + tm time20; + errorstate = good; + tim_get.get_date(is_it20, end, iss, errorstate, &time20); + VERIFY( time20.tm_mon == time_bday.tm_mon ); + VERIFY( time20.tm_mday == time_bday.tm_mday ); + VERIFY( time20.tm_year == time_bday.tm_year ); + VERIFY( errorstate == ios_base::eofbit ); +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_date/wchar_t/26701.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_date/wchar_t/26701.cc new file mode 100644 index 000000000..35c21d4b1 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_date/wchar_t/26701.cc @@ -0,0 +1,64 @@ +// { dg-require-namedlocale "en_GB" } + +// 2010-01-06 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +// libstdc++/26701 +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef istreambuf_iterator<wchar_t> iterator_type; + + locale loc_en = locale("en_GB"); + + tm tm0 = __gnu_test::test_tm(0, 0, 0, 0, 0, 0, 0, 0, 0); + + iterator_type end; + + wistringstream iss; + iss.imbue(loc_en); + const time_get<wchar_t>& tg = use_facet<time_get<wchar_t> >(iss.getloc()); + + const ios_base::iostate good = ios_base::goodbit; + ios_base::iostate errorstate = good; + + iss.str(L"01/02/2003"); + iterator_type is_it0(iss); + + errorstate = good; + tg.get_date(is_it0, end, iss, errorstate, &tm0); + VERIFY( errorstate == ios_base::eofbit ); + VERIFY( tm0.tm_year + 1900 == 2003 ); + VERIFY( tm0.tm_mon + 1 == 2 ); + VERIFY( tm0.tm_mday == 1 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_date/wchar_t/3.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_date/wchar_t/3.cc new file mode 100644 index 000000000..9d6aeca91 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_date/wchar_t/3.cc @@ -0,0 +1,71 @@ +// 2001-09-21 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +void test03() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + // Check time_get works with other iterators besides streambuf + // input iterators. + typedef wstring::const_iterator iter_type; + typedef time_get<wchar_t, iter_type> time_get_type; + const ios_base::iostate goodbit = ios_base::goodbit; + ios_base::iostate err = goodbit; + const locale loc_c = locale::classic(); + + // Create "C" time objects + const tm time_sanity = __gnu_test::test_tm(0, 0, 12, 26, 5, 97, 2, 0, 0); + tm tm1; + + istringstream iss; + iss.imbue(locale(loc_c, new time_get_type)); + + // Iterator advanced, state, output. + const time_get_type& tg = use_facet<time_get_type>(iss.getloc()); + + // Cindy Sherman's Untitled Film Stills + // June 26-September 2, 1997 + const wstring str = L"06/26/97 Tuesday September 1997 Cindy Sherman"; + + // 02 get_date + string res2; + err = goodbit; + // White space is not eaten, so manually increment past it. + iter_type end2 = tg.get_date(str.begin(), str.end(), iss, err, &tm1); + string rem2(end2, str.end()); + VERIFY( err == goodbit ); + VERIFY( tm1.tm_year == time_sanity.tm_year ); + VERIFY( tm1.tm_mon == time_sanity.tm_mon ); + VERIFY( tm1.tm_mday == time_sanity.tm_mday ); + VERIFY( rem2 == " Tuesday September 1997 Cindy Sherman" ); +} + +int main() +{ + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_date/wchar_t/4.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_date/wchar_t/4.cc new file mode 100644 index 000000000..7346380cd --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_date/wchar_t/4.cc @@ -0,0 +1,64 @@ +// { dg-require-namedlocale "zh_TW" } + +// 2003-12-17 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef istreambuf_iterator<wchar_t> iterator_type; + + locale loc_tw = locale("zh_TW"); + + iterator_type end; + + wistringstream iss; + iss.imbue(loc_tw); + const time_get<wchar_t>& tim_get = use_facet<time_get<wchar_t> >(iss.getloc()); + + const ios_base::iostate good = ios_base::goodbit; + ios_base::iostate errorstate = good; + + const wchar_t wstr[] = { 0x897f, 0x5143, L'2', L'0', L'0', L'3', + 0x5e74, L'1', L'2', 0x6708, L'1', L'7', + 0x65e5 , 0x0 }; + + iss.str(wstr); + iterator_type is_it01(iss); + tm time01; + tim_get.get_date(is_it01, end, iss, errorstate, &time01); + VERIFY( errorstate == ios_base::eofbit ); + VERIFY( time01.tm_mon == 11 ); + VERIFY( time01.tm_mday == 17 ); + VERIFY( time01.tm_year == 103 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_date/wchar_t/5.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_date/wchar_t/5.cc new file mode 100644 index 000000000..9110884fa --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_date/wchar_t/5.cc @@ -0,0 +1,70 @@ +// 2006-06-16 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2006, 2009, 2010 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +// Check that the err argument is ignored by get_date. +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef wstring::const_iterator iter_type; + typedef time_get<wchar_t, iter_type> time_get_type; + const ios_base::iostate goodbit = ios_base::goodbit; + const ios_base::iostate eofbit = ios_base::eofbit; + const ios_base::iostate failbit = ios_base::failbit; + ios_base::iostate err = goodbit; + const locale loc_c = locale::classic(); + + // Create "C" time objects + const tm time_sanity = __gnu_test::test_tm(0, 0, 12, 26, 5, 97, 2, 0, 0); + tm tm0 = __gnu_test::test_tm(0, 0, 0, 0, 0, 0, 0, 0, 0); + tm tm1 = __gnu_test::test_tm(0, 0, 0, 0, 0, 0, 0, 0, 0); + + wistringstream iss; + iss.imbue(locale(loc_c, new time_get_type)); + + const time_get_type& tg = use_facet<time_get_type>(iss.getloc()); + + const wstring str0 = L"1"; + tg.get_date(str0.begin(), str0.end(), iss, err, &tm0); + VERIFY( err == (failbit | eofbit) ); + VERIFY( tm0.tm_year == 0 ); + VERIFY( tm0.tm_mon == 0 ); + VERIFY( tm0.tm_mday == 0 ); + + const wstring str1 = L"06/26/97 "; + iter_type end1 = tg.get_date(str1.begin(), str1.end(), iss, err, &tm1); + VERIFY( err == (failbit | eofbit) ); + VERIFY( tm1.tm_year == time_sanity.tm_year ); + VERIFY( tm1.tm_mon == time_sanity.tm_mon ); + VERIFY( tm1.tm_mday == time_sanity.tm_mday ); + VERIFY( *end1 == L' ' ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_date/wchar_t/wrapped_env.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_date/wchar_t/wrapped_env.cc new file mode 100644 index 000000000..8f116717b --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_date/wchar_t/wrapped_env.cc @@ -0,0 +1,48 @@ +// { dg-require-namedlocale "de_DE" } +// { dg-require-namedlocale "en_HK" } + +// 2001-08-15 Benjamin Kosnik <bkoz@redhat.com> + +// 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.4.1.1 collate members + +#include <testsuite_hooks.h> + +#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 + +int main() +{ + using namespace __gnu_test; + func_callback two; + two.push_back(&test01); + two.push_back(&test02); + two.push_back(&test03); + run_tests_wrapped_env("de_DE", "LANG", two); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_date/wchar_t/wrapped_locale.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_date/wchar_t/wrapped_locale.cc new file mode 100644 index 000000000..a4edc45a8 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_date/wchar_t/wrapped_locale.cc @@ -0,0 +1,49 @@ +// { dg-require-namedlocale "ja_JP.eucjp" } +// { dg-require-namedlocale "de_DE" } +// { dg-require-namedlocale "en_HK" } + +// 2001-08-15 Benjamin Kosnik <bkoz@redhat.com> + +// 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.4.1.1 collate members + +#include <testsuite_hooks.h> + +#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 + +int main() +{ + using namespace __gnu_test; + func_callback two; + two.push_back(&test01); + two.push_back(&test02); + two.push_back(&test03); + run_tests_wrapped_locale("ja_JP.eucjp", two); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/char/1.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/char/1.cc new file mode 100644 index 000000000..9c0a72400 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/char/1.cc @@ -0,0 +1,116 @@ +// 2001-09-21 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef istreambuf_iterator<char> iterator_type; + + const ios_base::iostate good = ios_base::goodbit; + ios_base::iostate errorstate = good; + + // basic construction + locale loc_c = locale::classic(); + + // create "C" time objects + const tm time_bday = __gnu_test::test_tm(0, 0, 12, 4, 3, 71, 0, 93, 0); + + // iter_type + // get_monthname(iter_type, iter_type, ios_base&, + // ios_base::iostate&, tm*) const + + // sanity checks for "C" locale + iterator_type end; + istringstream iss; + iss.imbue(loc_c); + const time_get<char>& tim_get = use_facet<time_get<char> >(iss.getloc()); + + iss.str("April"); + iterator_type is_it01(iss); + tm time01; + errorstate = good; + tim_get.get_monthname(is_it01, end, iss, errorstate, &time01); + VERIFY( time01.tm_mon == time_bday.tm_mon ); + VERIFY( errorstate == ios_base::eofbit ); + + iss.str("Apr"); + iterator_type is_it02(iss); + tm time02; + errorstate = good; + tim_get.get_monthname(is_it02, end, iss, errorstate, &time02); + VERIFY( time02.tm_mon == time_bday.tm_mon ); + VERIFY( errorstate == ios_base::eofbit ); + + iss.str("Apr "); + iterator_type is_it03(iss); + tm time03; + errorstate = good; + iterator_type ret03 = tim_get.get_monthname(is_it03, end, iss, errorstate, + &time03); + VERIFY( time03.tm_mon == time_bday.tm_mon ); + VERIFY( errorstate == good ); + VERIFY( *ret03 == ' ' ); + + iss.str("Aar"); + iterator_type is_it04(iss); + tm time04; + time04.tm_mon = 5; + errorstate = good; + iterator_type ret04 = tim_get.get_monthname(is_it04, end, iss, errorstate, + &time04); + VERIFY( time04.tm_mon == 5 ); + VERIFY( *ret04 == 'a' ); + VERIFY( errorstate == ios_base::failbit ); + + iss.str("December "); + iterator_type is_it05(iss); + tm time05; + errorstate = good; + iterator_type ret05 = tim_get.get_monthname(is_it05, end, iss, errorstate, + &time05); + VERIFY( time05.tm_mon == 11 ); + VERIFY( errorstate == good ); + VERIFY( *ret05 == ' ' ); + + iss.str("Decelember "); + iterator_type is_it06(iss); + tm time06; + time06.tm_mon = 4; + errorstate = good; + iterator_type ret06 = tim_get.get_monthname(is_it06, end, iss, errorstate, + &time06); + VERIFY( time06.tm_mon == 4 ); + VERIFY( errorstate == ios_base::failbit ); + VERIFY( *ret06 == 'l' ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/char/2.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/char/2.cc new file mode 100644 index 000000000..dc117a37a --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/char/2.cc @@ -0,0 +1,82 @@ +// { dg-require-namedlocale "en_HK" } +// { dg-require-namedlocale "de_DE" } + +// 2001-09-21 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001, 2002, 2003, 2005, 2006, 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +void test02() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef istreambuf_iterator<char> iterator_type; + + // basic construction and sanity checks. + locale loc_c = locale::classic(); + locale loc_hk = locale("en_HK"); + locale loc_de = locale("de_DE"); + VERIFY( loc_hk != loc_c ); + VERIFY( loc_hk != loc_de ); + + const tm time_bday = __gnu_test::test_tm(0, 0, 12, 4, 3, 71, 0, 93, 0); + + const string empty; + + const ios_base::iostate good = ios_base::goodbit; + ios_base::iostate errorstate = good; + + // create an ostream-derived object, cache the time_get facet + iterator_type end; + + istringstream iss; + iss.imbue(loc_de); + const time_get<char>& tim_get = use_facet<time_get<char> >(iss.getloc()); + + // inspection of named locales, de_DE + iss.str("April"); + iterator_type is_it10(iss); + tm time10; + errorstate = good; + tim_get.get_monthname(is_it10, end, iss, errorstate, &time10); + VERIFY( time10.tm_mon == time_bday.tm_mon ); + VERIFY( errorstate == ios_base::eofbit ); + + // inspection of named locales, en_HK + iss.imbue(loc_hk); + const time_get<char>& tim_get2 = use_facet<time_get<char> >(iss.getloc()); + iss.str("April"); + iterator_type is_it20(iss); + tm time20; + errorstate = good; + tim_get2.get_monthname(is_it20, end, iss, errorstate, &time20); + VERIFY( time20.tm_mon == time_bday.tm_mon ); + VERIFY( errorstate == ios_base::eofbit ); +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/char/3.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/char/3.cc new file mode 100644 index 000000000..65394c20d --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/char/3.cc @@ -0,0 +1,67 @@ +// 2001-09-21 Benjamin Kosnik <bkoz@redhat.com> + +// 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +void test03() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + // Check time_get works with other iterators besides streambuf + // input iterators. + typedef string::const_iterator iter_type; + typedef time_get<char, iter_type> time_get_type; + const ios_base::iostate goodbit = ios_base::goodbit; + ios_base::iostate err = goodbit; + const locale loc_c = locale::classic(); + + // Create "C" time objects + tm tm1; + + istringstream iss; + iss.imbue(locale(loc_c, new time_get_type)); + + // Iterator advanced, state, output. + const time_get_type& tg = use_facet<time_get_type>(iss.getloc()); + + // Cindy Sherman's Untitled Film Stills + // June 26-September 2, 1997 + const string str = "September 1997 Cindy Sherman"; + + // 04 get_monthname + string res4; + err = goodbit; + // White space is not eaten, so manually increment past it. + iter_type end4 = tg.get_monthname(str.begin(), str.end(), iss, err, &tm1); + string rem4(end4, str.end()); + VERIFY( err == goodbit ); + VERIFY( tm1.tm_mon == 8 ); + VERIFY( rem4 == " 1997 Cindy Sherman" ); +} + +int main() +{ + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/char/4.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/char/4.cc new file mode 100644 index 000000000..5792a0e0b --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/char/4.cc @@ -0,0 +1,58 @@ +// 2004-04-07 Paolo Carlini <pcarlini@suse.de> + +// 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef istreambuf_iterator<char> iterator_type; + + const ios_base::iostate good = ios_base::goodbit; + ios_base::iostate errorstate = good; + + // basic construction + locale loc_c = locale::classic(); + + iterator_type end; + istringstream iss; + iss.imbue(loc_c); + const time_get<char>& tim_get = + use_facet<time_get<char> >(iss.getloc()); + + iss.str("Jul"); + iterator_type is_it01(iss); + tm time01; + errorstate = good; + tim_get.get_monthname(is_it01, end, iss, errorstate, &time01); + VERIFY( time01.tm_mon == 6 ); + VERIFY( errorstate == ios_base::eofbit ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/char/5.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/char/5.cc new file mode 100644 index 000000000..c1966fe4b --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/char/5.cc @@ -0,0 +1,66 @@ +// 2006-06-16 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2006, 2009, 2010 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +// Check that the err argument is ignored by get_monthname. +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef string::const_iterator iter_type; + typedef time_get<char, iter_type> time_get_type; + const ios_base::iostate goodbit = ios_base::goodbit; + const ios_base::iostate eofbit = ios_base::eofbit; + const ios_base::iostate failbit = ios_base::failbit; + ios_base::iostate err = goodbit; + const locale loc_c = locale::classic(); + + // Create "C" time objects + tm tm0 = __gnu_test::test_tm(0, 0, 0, 0, 0, 0, 0, 0, 0); + tm tm1 = __gnu_test::test_tm(0, 0, 0, 0, 0, 0, 0, 0, 0); + + istringstream iss; + iss.imbue(locale(loc_c, new time_get_type)); + + // Iterator advanced, state, output. + const time_get_type& tg = use_facet<time_get_type>(iss.getloc()); + + const string str0 = "S"; + tg.get_monthname(str0.begin(), str0.end(), iss, err, &tm0); + VERIFY( err == (failbit | eofbit) ); + VERIFY( tm0.tm_mon == 0 ); + + const string str1 = "September "; + iter_type end1 = tg.get_monthname(str1.begin(), str1.end(), iss, err, &tm1); + VERIFY( err == (failbit | eofbit) ); + VERIFY( tm1.tm_mon == 8 ); + VERIFY( *end1 == ' ' ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/char/6.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/char/6.cc new file mode 100644 index 000000000..2083db617 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/char/6.cc @@ -0,0 +1,89 @@ +// 2010-01-05 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <cstring> +#include <testsuite_hooks.h> + +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef istreambuf_iterator<char> iterator_type; + + // basic construction + locale loc_c = locale::classic(); + + // create an ostream-derived object, cache the time_get facet + iterator_type end; + + istringstream iss; + iss.imbue(loc_c); + const time_get<char>& tim_get = use_facet<time_get<char> >(iss.getloc()); + + const ios_base::iostate good = ios_base::goodbit; + ios_base::iostate errorstate = good; + + // iter_type + // get_monthname(iter_type, iter_type, ios_base&, + // ios_base::iostate&, tm*) const + + // sanity checks for "C" locale + + const char* amname[12] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; + + for (int i = 0; i < 12; ++i) + { + iss.str(amname[i]); + iterator_type is_it01(iss); + tm time01; + memset(&time01, -1, sizeof(tm)); + errorstate = good; + tim_get.get_monthname(is_it01, end, iss, errorstate, &time01); + VERIFY( time01.tm_mon == i ); + VERIFY( errorstate == ios_base::eofbit ); + } + + const char* mname[12] = { "January", "February", "March", "April", + "May", "June", "July", "August", + "September", "October", "November", "December" }; + + for (int i = 0; i < 12; ++i) + { + iss.str(mname[i]); + iterator_type is_it01(iss); + tm time01; + memset(&time01, -1, sizeof(tm)); + errorstate = good; + tim_get.get_monthname(is_it01, end, iss, errorstate, &time01); + VERIFY( time01.tm_mon == i ); + VERIFY( errorstate == ios_base::eofbit ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/char/wrapped_env.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/char/wrapped_env.cc new file mode 100644 index 000000000..8f116717b --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/char/wrapped_env.cc @@ -0,0 +1,48 @@ +// { dg-require-namedlocale "de_DE" } +// { dg-require-namedlocale "en_HK" } + +// 2001-08-15 Benjamin Kosnik <bkoz@redhat.com> + +// 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.4.1.1 collate members + +#include <testsuite_hooks.h> + +#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 + +int main() +{ + using namespace __gnu_test; + func_callback two; + two.push_back(&test01); + two.push_back(&test02); + two.push_back(&test03); + run_tests_wrapped_env("de_DE", "LANG", two); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/char/wrapped_locale.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/char/wrapped_locale.cc new file mode 100644 index 000000000..a4edc45a8 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/char/wrapped_locale.cc @@ -0,0 +1,49 @@ +// { dg-require-namedlocale "ja_JP.eucjp" } +// { dg-require-namedlocale "de_DE" } +// { dg-require-namedlocale "en_HK" } + +// 2001-08-15 Benjamin Kosnik <bkoz@redhat.com> + +// 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.4.1.1 collate members + +#include <testsuite_hooks.h> + +#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 + +int main() +{ + using namespace __gnu_test; + func_callback two; + two.push_back(&test01); + two.push_back(&test02); + two.push_back(&test03); + run_tests_wrapped_locale("ja_JP.eucjp", two); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/wchar_t/1.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/wchar_t/1.cc new file mode 100644 index 000000000..cdc7f621e --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/wchar_t/1.cc @@ -0,0 +1,116 @@ +// 2001-09-21 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef istreambuf_iterator<wchar_t> iterator_type; + + const ios_base::iostate good = ios_base::goodbit; + ios_base::iostate errorstate = good; + + // basic construction + locale loc_c = locale::classic(); + + // create "C" time objects + const tm time_bday = __gnu_test::test_tm(0, 0, 12, 4, 3, 71, 0, 93, 0); + + // iter_type + // get_monthname(iter_type, iter_type, ios_base&, + // ios_base::iostate&, tm*) const + + // sanity checks for "C" locale + iterator_type end; + wistringstream iss; + iss.imbue(loc_c); + const time_get<wchar_t>& tim_get = use_facet<time_get<wchar_t> >(iss.getloc()); + + iss.str(L"April"); + iterator_type is_it01(iss); + tm time01; + errorstate = good; + tim_get.get_monthname(is_it01, end, iss, errorstate, &time01); + VERIFY( time01.tm_mon == time_bday.tm_mon ); + VERIFY( errorstate == ios_base::eofbit ); + + iss.str(L"Apr"); + iterator_type is_it02(iss); + tm time02; + errorstate = good; + tim_get.get_monthname(is_it02, end, iss, errorstate, &time02); + VERIFY( time02.tm_mon == time_bday.tm_mon ); + VERIFY( errorstate == ios_base::eofbit ); + + iss.str(L"Apr "); + iterator_type is_it03(iss); + tm time03; + errorstate = good; + iterator_type ret03 = tim_get.get_monthname(is_it03, end, iss, errorstate, + &time03); + VERIFY( time03.tm_mon == time_bday.tm_mon ); + VERIFY( errorstate == good ); + VERIFY( *ret03 == L' ' ); + + iss.str(L"Aar"); + iterator_type is_it04(iss); + tm time04; + time04.tm_mon = 5; + errorstate = good; + iterator_type ret04 = tim_get.get_monthname(is_it04, end, iss, errorstate, + &time04); + VERIFY( time04.tm_mon == 5 ); + VERIFY( *ret04 == L'a' ); + VERIFY( errorstate == ios_base::failbit ); + + iss.str(L"December "); + iterator_type is_it05(iss); + tm time05; + errorstate = good; + iterator_type ret05 = tim_get.get_monthname(is_it05, end, iss, errorstate, + &time05); + VERIFY( time05.tm_mon == 11 ); + VERIFY( errorstate == good ); + VERIFY( *ret05 == L' ' ); + + iss.str(L"Decelember "); + iterator_type is_it06(iss); + tm time06; + time06.tm_mon = 4; + errorstate = good; + iterator_type ret06 = tim_get.get_monthname(is_it06, end, iss, errorstate, + &time06); + VERIFY( time06.tm_mon == 4 ); + VERIFY( errorstate == ios_base::failbit ); + VERIFY( *ret06 == L'l' ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/wchar_t/2.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/wchar_t/2.cc new file mode 100644 index 000000000..89ed391dd --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/wchar_t/2.cc @@ -0,0 +1,83 @@ +// { dg-require-namedlocale "en_HK" } +// { dg-require-namedlocale "de_DE" } + +// 2001-09-21 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +void test02() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef istreambuf_iterator<wchar_t> iterator_type; + + // basic construction and sanity checks. + locale loc_c = locale::classic(); + locale loc_hk = locale("en_HK"); + locale loc_de = locale("de_DE"); + VERIFY( loc_hk != loc_c ); + VERIFY( loc_hk != loc_de ); + + const tm time_bday = __gnu_test::test_tm(0, 0, 12, 4, 3, 71, 0, 93, 0); + + const wstring empty; + + const ios_base::iostate good = ios_base::goodbit; + ios_base::iostate errorstate = good; + + // create an ostream-derived object, cache the time_get facet + iterator_type end; + + wistringstream iss; + iss.imbue(loc_de); + const time_get<wchar_t>& tim_get = use_facet<time_get<wchar_t> >(iss.getloc()); + + // inspection of named locales, de_DE + iss.str(L"April"); + iterator_type is_it10(iss); + tm time10; + errorstate = good; + tim_get.get_monthname(is_it10, end, iss, errorstate, &time10); + VERIFY( time10.tm_mon == time_bday.tm_mon ); + VERIFY( errorstate == ios_base::eofbit ); + + // inspection of named locales, en_HK + iss.imbue(loc_hk); + const time_get<wchar_t>& tim_get2 = use_facet<time_get<wchar_t> >(iss.getloc()); + iss.str(L"April"); + iterator_type is_it20(iss); + tm time20; + errorstate = good; + tim_get2.get_monthname(is_it20, end, iss, errorstate, &time20); + VERIFY( time20.tm_mon == time_bday.tm_mon ); + VERIFY( errorstate == ios_base::eofbit ); +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/wchar_t/3.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/wchar_t/3.cc new file mode 100644 index 000000000..48174173e --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/wchar_t/3.cc @@ -0,0 +1,67 @@ +// 2001-09-21 Benjamin Kosnik <bkoz@redhat.com> + +// 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +void test03() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + // Check time_get works with other iterators besides streambuf + // input iterators. + typedef wstring::const_iterator iter_type; + typedef time_get<wchar_t, iter_type> time_get_type; + const ios_base::iostate goodbit = ios_base::goodbit; + ios_base::iostate err = goodbit; + const locale loc_c = locale::classic(); + + // Create "C" time objects + tm tm1; + + istringstream iss; + iss.imbue(locale(loc_c, new time_get_type)); + + // Iterator advanced, state, output. + const time_get_type& tg = use_facet<time_get_type>(iss.getloc()); + + // Cindy Sherman's Untitled Film Stills + // June 26-September 2, 1997 + const wstring str = L"September 1997 Cindy Sherman"; + + // 04 get_monthname + wstring res4; + err = goodbit; + // White space is not eaten, so manually increment past it. + iter_type end4 = tg.get_monthname(str.begin(), str.end(), iss, err, &tm1); + wstring rem4(end4, str.end()); + VERIFY( err == goodbit ); + VERIFY( tm1.tm_mon == 8 ); + VERIFY( rem4 == L" 1997 Cindy Sherman" ); +} + +int main() +{ + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/wchar_t/4.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/wchar_t/4.cc new file mode 100644 index 000000000..d734d97b6 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/wchar_t/4.cc @@ -0,0 +1,58 @@ +// 2004-04-07 Paolo Carlini <pcarlini@suse.de> + +// 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef istreambuf_iterator<wchar_t> iterator_type; + + const ios_base::iostate good = ios_base::goodbit; + ios_base::iostate errorstate = good; + + // basic construction + locale loc_c = locale::classic(); + + iterator_type end; + wistringstream iss; + iss.imbue(loc_c); + const time_get<wchar_t>& tim_get = + use_facet<time_get<wchar_t> >(iss.getloc()); + + iss.str(L"Jul"); + iterator_type is_it01(iss); + tm time01; + errorstate = good; + tim_get.get_monthname(is_it01, end, iss, errorstate, &time01); + VERIFY( time01.tm_mon == 6 ); + VERIFY( errorstate == ios_base::eofbit ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/wchar_t/5.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/wchar_t/5.cc new file mode 100644 index 000000000..192d19c94 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/wchar_t/5.cc @@ -0,0 +1,66 @@ +// 2006-06-16 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2006, 2009, 2010 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +// Check that the err argument is ignored by get_monthname. +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef wstring::const_iterator iter_type; + typedef time_get<wchar_t, iter_type> time_get_type; + const ios_base::iostate goodbit = ios_base::goodbit; + const ios_base::iostate eofbit = ios_base::eofbit; + const ios_base::iostate failbit = ios_base::failbit; + ios_base::iostate err = goodbit; + const locale loc_c = locale::classic(); + + // Create "C" time objects + tm tm0 = __gnu_test::test_tm(0, 0, 0, 0, 0, 0, 0, 0, 0); + tm tm1 = __gnu_test::test_tm(0, 0, 0, 0, 0, 0, 0, 0, 0); + + wistringstream iss; + iss.imbue(locale(loc_c, new time_get_type)); + + // Iterator advanced, state, output. + const time_get_type& tg = use_facet<time_get_type>(iss.getloc()); + + const wstring str0 = L"S"; + tg.get_monthname(str0.begin(), str0.end(), iss, err, &tm0); + VERIFY( err == (failbit | eofbit) ); + VERIFY( tm0.tm_mon == 0 ); + + const wstring str1 = L"September "; + iter_type end1 = tg.get_monthname(str1.begin(), str1.end(), iss, err, &tm1); + VERIFY( err == (failbit | eofbit) ); + VERIFY( tm1.tm_mon == 8 ); + VERIFY( *end1 == L' ' ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/wchar_t/6.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/wchar_t/6.cc new file mode 100644 index 000000000..7f9f47fb8 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/wchar_t/6.cc @@ -0,0 +1,92 @@ +// 2010-01-05 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <cstring> +#include <testsuite_hooks.h> + +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef istreambuf_iterator<wchar_t> iterator_type; + + // basic construction + locale loc_c = locale::classic(); + + // create an ostream-derived object, cache the time_get facet + iterator_type end; + + wistringstream iss; + iss.imbue(loc_c); + const time_get<wchar_t>& tim_get + = use_facet<time_get<wchar_t> >(iss.getloc()); + + const ios_base::iostate good = ios_base::goodbit; + ios_base::iostate errorstate = good; + + // iter_type + // get_monthname(iter_type, iter_type, ios_base&, + // ios_base::iostate&, tm*) const + + // sanity checks for "C" locale + + const wchar_t* amname[12] = { L"Jan", L"Feb", L"Mar", L"Apr", + L"May", L"Jun", L"Jul", L"Aug", + L"Sep", L"Oct", L"Nov", L"Dec" }; + + for (int i = 0; i < 12; ++i) + { + iss.str(amname[i]); + iterator_type is_it01(iss); + tm time01; + memset(&time01, -1, sizeof(tm)); + errorstate = good; + tim_get.get_monthname(is_it01, end, iss, errorstate, &time01); + VERIFY( time01.tm_mon == i ); + VERIFY( errorstate == ios_base::eofbit ); + } + + const wchar_t* mname[12] = { L"January", L"February", L"March", + L"April", L"May", L"June", + L"July", L"August", L"September", + L"October", L"November", L"December" }; + + for (int i = 0; i < 12; ++i) + { + iss.str(mname[i]); + iterator_type is_it01(iss); + tm time01; + memset(&time01, -1, sizeof(tm)); + errorstate = good; + tim_get.get_monthname(is_it01, end, iss, errorstate, &time01); + VERIFY( time01.tm_mon == i ); + VERIFY( errorstate == ios_base::eofbit ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/wchar_t/wrapped_env.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/wchar_t/wrapped_env.cc new file mode 100644 index 000000000..8f116717b --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/wchar_t/wrapped_env.cc @@ -0,0 +1,48 @@ +// { dg-require-namedlocale "de_DE" } +// { dg-require-namedlocale "en_HK" } + +// 2001-08-15 Benjamin Kosnik <bkoz@redhat.com> + +// 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.4.1.1 collate members + +#include <testsuite_hooks.h> + +#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 + +int main() +{ + using namespace __gnu_test; + func_callback two; + two.push_back(&test01); + two.push_back(&test02); + two.push_back(&test03); + run_tests_wrapped_env("de_DE", "LANG", two); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/wchar_t/wrapped_locale.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/wchar_t/wrapped_locale.cc new file mode 100644 index 000000000..a4edc45a8 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/wchar_t/wrapped_locale.cc @@ -0,0 +1,49 @@ +// { dg-require-namedlocale "ja_JP.eucjp" } +// { dg-require-namedlocale "de_DE" } +// { dg-require-namedlocale "en_HK" } + +// 2001-08-15 Benjamin Kosnik <bkoz@redhat.com> + +// 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.4.1.1 collate members + +#include <testsuite_hooks.h> + +#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 + +int main() +{ + using namespace __gnu_test; + func_callback two; + two.push_back(&test01); + two.push_back(&test02); + two.push_back(&test03); + run_tests_wrapped_locale("ja_JP.eucjp", two); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_time/char/1.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_time/char/1.cc new file mode 100644 index 000000000..69cf0d5dc --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_time/char/1.cc @@ -0,0 +1,115 @@ +// { dg-require-namedlocale "de_DE" } + +// 2001-09-21 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef istreambuf_iterator<char> iterator_type; + + // basic construction and sanity checks. + locale loc_c = locale::classic(); + locale loc_de = locale("de_DE"); + VERIFY( loc_de != loc_c ); + + const string empty; + + // create an ostream-derived object, cache the time_get facet + iterator_type end; + istringstream iss; + iss.imbue(loc_c); + const time_get<char>& tim_get = use_facet<time_get<char> >(iss.getloc()); + + const ios_base::iostate good = ios_base::goodbit; + ios_base::iostate errorstate = good; + + // create "C" time objects + const tm time_bday = __gnu_test::test_tm(0, 0, 12, 4, 3, 71, 0, 93, 0); + + // 2 + // iter_type + // get_time(iter_type, iter_type, ios_base&, ios_base::iostate&, tm*) const + + // sanity checks for "C" locale + iss.str("12:00:00"); + iterator_type is_it01(iss); + tm time01; + errorstate = good; + tim_get.get_time(is_it01, end, iss, errorstate, &time01); + VERIFY( time01.tm_sec == time_bday.tm_sec ); + VERIFY( time01.tm_min == time_bday.tm_min ); + VERIFY( time01.tm_hour == time_bday.tm_hour ); + VERIFY( errorstate == ios_base::eofbit ); + + iss.str("12:00:00 "); + iterator_type is_it02(iss); + tm time02; + errorstate = good; + tim_get.get_time(is_it02, end, iss, errorstate, &time02); + VERIFY( time01.tm_sec == time_bday.tm_sec ); + VERIFY( time01.tm_min == time_bday.tm_min ); + VERIFY( time01.tm_hour == time_bday.tm_hour ); + VERIFY( errorstate == good ); + + iss.str("12:61:00 "); + iterator_type is_it03(iss); + tm time03; + errorstate = good; + tim_get.get_time(is_it03, end, iss, errorstate, &time03); + VERIFY( time01.tm_hour == time_bday.tm_hour ); + VERIFY( errorstate == ios_base::failbit ); + + iss.str("12:a:00 "); + iterator_type is_it04(iss); + tm time04; + errorstate = good; + iterator_type ret04 = tim_get.get_time(is_it04, end, iss, errorstate, + &time04); + VERIFY( time01.tm_hour == time_bday.tm_hour ); + VERIFY( *ret04 == 'a' ); + VERIFY( errorstate == ios_base::failbit ); + + // inspection of named locales, de_DE + iss.imbue(loc_de); + iss.str("12:00:00"); + iterator_type is_it10(iss); + tm time10; + errorstate = good; + tim_get.get_time(is_it10, end, iss, errorstate, &time10); + VERIFY( time10.tm_sec == time_bday.tm_sec ); + VERIFY( time10.tm_min == time_bday.tm_min ); + VERIFY( time10.tm_hour == time_bday.tm_hour ); + VERIFY( errorstate == ios_base::eofbit ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_time/char/2.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_time/char/2.cc new file mode 100644 index 000000000..0df532247 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_time/char/2.cc @@ -0,0 +1,71 @@ +// { dg-require-namedlocale "en_HK" } + +// 2001-09-21 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +void test02() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef istreambuf_iterator<char> iterator_type; + + // basic construction and sanity check + locale loc_c = locale::classic(); + locale loc_hk = locale("en_HK"); + VERIFY( loc_hk != loc_c ); + + const string empty; + const tm time_bday = __gnu_test::test_tm(0, 0, 12, 4, 3, 71, 0, 93, 0); + + // create an ostream-derived object, cache the time_get facet + iterator_type end; + istringstream iss; + const time_get<char>& tim_get = use_facet<time_get<char> >(iss.getloc()); + const ios_base::iostate good = ios_base::goodbit; + ios_base::iostate errorstate = good; + + // inspection of named locales, en_HK + iss.imbue(loc_hk); + iss.str("12:00:00 PST"); + // Hong Kong in California! Well, they have Paris in Vegas... this + // is all a little disney-esque anyway. Besides, you can get decent + // Dim Sum in San Francisco. + iterator_type is_it20(iss); + tm time20; + errorstate = good; + tim_get.get_time(is_it20, end, iss, errorstate, &time20); + VERIFY( time20.tm_sec == time_bday.tm_sec ); + VERIFY( time20.tm_min == time_bday.tm_min ); + VERIFY( time20.tm_hour == time_bday.tm_hour ); + VERIFY( errorstate == ios_base::eofbit ); +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_time/char/3.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_time/char/3.cc new file mode 100644 index 000000000..e5589970e --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_time/char/3.cc @@ -0,0 +1,70 @@ +// 2001-09-21 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +void test03() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + // Check time_get works with other iterators besides streambuf + // input iterators. + typedef string::const_iterator iter_type; + typedef time_get<char, iter_type> time_get_type; + const ios_base::iostate goodbit = ios_base::goodbit; + ios_base::iostate err = goodbit; + const locale loc_c = locale::classic(); + + // Create "C" time objects + const tm time_sanity = __gnu_test::test_tm(0, 0, 12, 26, 5, 97, 2, 0, 0); + tm tm1; + + istringstream iss; + iss.imbue(locale(loc_c, new time_get_type)); + + // Iterator advanced, state, output. + const time_get_type& tg = use_facet<time_get_type>(iss.getloc()); + + // Cindy Sherman's Untitled Film Stills + // June 26-September 2, 1997 + const string str = "12:00:00 06/26/97 Tuesday September 1997 Cindy Sherman"; + + // 01 get_time + string res1; + err = goodbit; + iter_type end1 = tg.get_time(str.begin(), str.end(), iss, err, &tm1); + string rem1(end1, str.end()); + VERIFY( err == goodbit ); + VERIFY( tm1.tm_sec == time_sanity.tm_sec ); + VERIFY( tm1.tm_min == time_sanity.tm_min ); + VERIFY( tm1.tm_hour == time_sanity.tm_hour ); + VERIFY( rem1 == " 06/26/97 Tuesday September 1997 Cindy Sherman" ); +} + +int main() +{ + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_time/char/4.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_time/char/4.cc new file mode 100644 index 000000000..197b014b2 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_time/char/4.cc @@ -0,0 +1,63 @@ +// 2004-08-29 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2004, 2005, 2006, 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +// Allow for one leap-second (two if !_GLIBCXX_USE_C99). +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef istreambuf_iterator<char> iterator_type; + + // basic construction and sanity checks. + locale loc_c = locale::classic(); + + // create an istream-derived object, cache the time_get facet + iterator_type end; + istringstream iss; + iss.imbue(loc_c); + const time_get<char>& tim_get = + use_facet<time_get<char> >(iss.getloc()); + + const ios_base::iostate good = ios_base::goodbit; + ios_base::iostate errorstate = good; + + // create "C" time objects + const tm time_bday = __gnu_test::test_tm(60, 0, 12, 4, 3, 71, 0, 93, 0); + + iss.str("12:00:60 "); + iterator_type is_it01(iss); + tm time01; + errorstate = good; + tim_get.get_time(is_it01, end, iss, errorstate, &time01); + VERIFY( time01.tm_sec == time_bday.tm_sec ); + VERIFY( errorstate == ios_base::goodbit ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_time/char/5.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_time/char/5.cc new file mode 100644 index 000000000..b099b6e7b --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_time/char/5.cc @@ -0,0 +1,71 @@ +// 2006-06-16 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2006, 2009, 2010 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +// Check that the err argument is ignored by get_time. +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef string::const_iterator iter_type; + typedef time_get<char, iter_type> time_get_type; + const ios_base::iostate goodbit = ios_base::goodbit; + const ios_base::iostate eofbit = ios_base::eofbit; + const ios_base::iostate failbit = ios_base::failbit; + ios_base::iostate err = goodbit; + const locale loc_c = locale::classic(); + + // Create "C" time objects + const tm time_sanity = __gnu_test::test_tm(0, 0, 12, 26, 5, 97, 2, 0, 0); + tm tm0 = __gnu_test::test_tm(0, 0, 0, 0, 0, 0, 0, 0, 0); + tm tm1 = __gnu_test::test_tm(0, 0, 0, 0, 0, 0, 0, 0, 0); + + istringstream iss; + iss.imbue(locale(loc_c, new time_get_type)); + + // Iterator advanced, state, output. + const time_get_type& tg = use_facet<time_get_type>(iss.getloc()); + + const string str0 = "1"; + tg.get_time(str0.begin(), str0.end(), iss, err, &tm0); + VERIFY( err == (failbit | eofbit) ); + VERIFY( tm0.tm_sec == 0 ); + VERIFY( tm0.tm_min == 0 ); + VERIFY( tm0.tm_hour == 0 ); + + const string str1 = "12:00:00 "; + iter_type end1 = tg.get_time(str1.begin(), str1.end(), iss, err, &tm1); + VERIFY( err == (failbit | eofbit) ); + VERIFY( tm1.tm_sec == time_sanity.tm_sec ); + VERIFY( tm1.tm_min == time_sanity.tm_min ); + VERIFY( tm1.tm_hour == time_sanity.tm_hour ); + VERIFY( *end1 == ' ' ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_time/char/6.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_time/char/6.cc new file mode 100644 index 000000000..9ecd93ff4 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_time/char/6.cc @@ -0,0 +1,71 @@ +// 2010-10-07 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010 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 +// <http://www.gnu.org/licenses/>. + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef string::const_iterator iter_type; + typedef time_get<char, iter_type> time_get_type; + const ios_base::iostate goodbit = ios_base::goodbit; + const ios_base::iostate eofbit = ios_base::eofbit; + const ios_base::iostate failbit = ios_base::failbit; + ios_base::iostate err = goodbit; + const locale loc_c = locale::classic(); + + // Create "C" time objects + tm tm0 = __gnu_test::test_tm(0, 0, 0, 0, 0, 0, 0, 0, 0); + tm tm1 = __gnu_test::test_tm(0, 0, 0, 0, 0, 0, 0, 0, 0); + + istringstream iss; + iss.imbue(locale(loc_c, new time_get_type)); + + // Iterator advanced, state, output. + const time_get_type& tg = use_facet<time_get_type>(iss.getloc()); + + const string str0 = "12"; + tg.get_time(str0.begin(), str0.end(), iss, err, &tm0); + VERIFY( err == (failbit | eofbit) ); + VERIFY( tm0.tm_sec == 0 ); + VERIFY( tm0.tm_min == 0 ); + // This is quite hard to guarantee now, revisit together with DR 461 + // in the C++0x context. + // VERIFY( tm0.tm_hour == 0 ); + + const string str1 = "12:30 "; + err = goodbit; + iter_type end1 = tg.get_time(str1.begin(), str1.end(), iss, err, &tm1); + VERIFY( err == failbit ); + VERIFY( *end1 == ' ' ); + VERIFY( tm1.tm_sec == 0 ); + // See above... + // VERIFY( tm1.tm_min == 0 ); + // VERIFY( tm1.tm_hour == 0 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_time/char/wrapped_env.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_time/char/wrapped_env.cc new file mode 100644 index 000000000..8f116717b --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_time/char/wrapped_env.cc @@ -0,0 +1,48 @@ +// { dg-require-namedlocale "de_DE" } +// { dg-require-namedlocale "en_HK" } + +// 2001-08-15 Benjamin Kosnik <bkoz@redhat.com> + +// 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.4.1.1 collate members + +#include <testsuite_hooks.h> + +#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 + +int main() +{ + using namespace __gnu_test; + func_callback two; + two.push_back(&test01); + two.push_back(&test02); + two.push_back(&test03); + run_tests_wrapped_env("de_DE", "LANG", two); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_time/char/wrapped_locale.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_time/char/wrapped_locale.cc new file mode 100644 index 000000000..a4edc45a8 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_time/char/wrapped_locale.cc @@ -0,0 +1,49 @@ +// { dg-require-namedlocale "ja_JP.eucjp" } +// { dg-require-namedlocale "de_DE" } +// { dg-require-namedlocale "en_HK" } + +// 2001-08-15 Benjamin Kosnik <bkoz@redhat.com> + +// 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.4.1.1 collate members + +#include <testsuite_hooks.h> + +#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 + +int main() +{ + using namespace __gnu_test; + func_callback two; + two.push_back(&test01); + two.push_back(&test02); + two.push_back(&test03); + run_tests_wrapped_locale("ja_JP.eucjp", two); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_time/wchar_t/1.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_time/wchar_t/1.cc new file mode 100644 index 000000000..ad8a468c5 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_time/wchar_t/1.cc @@ -0,0 +1,115 @@ +// { dg-require-namedlocale "de_DE" } + +// 2001-09-21 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef istreambuf_iterator<wchar_t> iterator_type; + + // basic construction and sanity checks. + locale loc_c = locale::classic(); + locale loc_de = locale("de_DE"); + VERIFY( loc_de != loc_c ); + + const wstring empty; + + // create an ostream-derived object, cache the time_get facet + iterator_type end; + wistringstream iss; + iss.imbue(loc_c); + const time_get<wchar_t>& tim_get = use_facet<time_get<wchar_t> >(iss.getloc()); + + const ios_base::iostate good = ios_base::goodbit; + ios_base::iostate errorstate = good; + + // create "C" time objects + const tm time_bday = __gnu_test::test_tm(0, 0, 12, 4, 3, 71, 0, 93, 0); + + // 2 + // iter_type + // get_time(iter_type, iter_type, ios_base&, ios_base::iostate&, tm*) const + + // sanity checks for "C" locale + iss.str(L"12:00:00"); + iterator_type is_it01(iss); + tm time01; + errorstate = good; + tim_get.get_time(is_it01, end, iss, errorstate, &time01); + VERIFY( time01.tm_sec == time_bday.tm_sec ); + VERIFY( time01.tm_min == time_bday.tm_min ); + VERIFY( time01.tm_hour == time_bday.tm_hour ); + VERIFY( errorstate == ios_base::eofbit ); + + iss.str(L"12:00:00 "); + iterator_type is_it02(iss); + tm time02; + errorstate = good; + tim_get.get_time(is_it02, end, iss, errorstate, &time02); + VERIFY( time01.tm_sec == time_bday.tm_sec ); + VERIFY( time01.tm_min == time_bday.tm_min ); + VERIFY( time01.tm_hour == time_bday.tm_hour ); + VERIFY( errorstate == good ); + + iss.str(L"12:61:00 "); + iterator_type is_it03(iss); + tm time03; + errorstate = good; + tim_get.get_time(is_it03, end, iss, errorstate, &time03); + VERIFY( time01.tm_hour == time_bday.tm_hour ); + VERIFY( errorstate == ios_base::failbit ); + + iss.str(L"12:a:00 "); + iterator_type is_it04(iss); + tm time04; + errorstate = good; + iterator_type ret04 = tim_get.get_time(is_it04, end, iss, errorstate, + &time04); + VERIFY( time01.tm_hour == time_bday.tm_hour ); + VERIFY( *ret04 == L'a' ); + VERIFY( errorstate == ios_base::failbit ); + + // inspection of named locales, de_DE + iss.imbue(loc_de); + iss.str(L"12:00:00"); + iterator_type is_it10(iss); + tm time10; + errorstate = good; + tim_get.get_time(is_it10, end, iss, errorstate, &time10); + VERIFY( time10.tm_sec == time_bday.tm_sec ); + VERIFY( time10.tm_min == time_bday.tm_min ); + VERIFY( time10.tm_hour == time_bday.tm_hour ); + VERIFY( errorstate == ios_base::eofbit ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_time/wchar_t/2.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_time/wchar_t/2.cc new file mode 100644 index 000000000..72946612b --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_time/wchar_t/2.cc @@ -0,0 +1,71 @@ +// { dg-require-namedlocale "en_HK" } + +// 2001-09-21 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +void test02() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef istreambuf_iterator<wchar_t> iterator_type; + + // basic construction and sanity check + locale loc_c = locale::classic(); + locale loc_hk = locale("en_HK"); + VERIFY( loc_hk != loc_c ); + + const wstring empty; + const tm time_bday = __gnu_test::test_tm(0, 0, 12, 4, 3, 71, 0, 93, 0); + + // create an ostream-derived object, cache the time_get facet + iterator_type end; + wistringstream iss; + const time_get<wchar_t>& tim_get = use_facet<time_get<wchar_t> >(iss.getloc()); + const ios_base::iostate good = ios_base::goodbit; + ios_base::iostate errorstate = good; + + // inspection of named locales, en_HK + iss.imbue(loc_hk); + iss.str(L"12:00:00 PST"); + // Hong Kong in California! Well, they have Paris in Vegas... this + // is all a little disney-esque anyway. Besides, you can get decent + // Dim Sum in San Francisco. + iterator_type is_it20(iss); + tm time20; + errorstate = good; + tim_get.get_time(is_it20, end, iss, errorstate, &time20); + VERIFY( time20.tm_sec == time_bday.tm_sec ); + VERIFY( time20.tm_min == time_bday.tm_min ); + VERIFY( time20.tm_hour == time_bday.tm_hour ); + VERIFY( errorstate == ios_base::eofbit ); +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_time/wchar_t/3.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_time/wchar_t/3.cc new file mode 100644 index 000000000..b032c0ee9 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_time/wchar_t/3.cc @@ -0,0 +1,70 @@ +// 2001-09-21 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +void test03() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + // Check time_get works with other iterators besides streambuf + // input iterators. + typedef wstring::const_iterator iter_type; + typedef time_get<wchar_t, iter_type> time_get_type; + const ios_base::iostate goodbit = ios_base::goodbit; + ios_base::iostate err = goodbit; + const locale loc_c = locale::classic(); + + // Create "C" time objects + const tm time_sanity = __gnu_test::test_tm(0, 0, 12, 26, 5, 97, 2, 0, 0); + tm tm1; + + wistringstream iss; + iss.imbue(locale(loc_c, new time_get_type)); + + // Iterator advanced, state, output. + const time_get_type& tg = use_facet<time_get_type>(iss.getloc()); + + // Cindy Sherman's Untitled Film Stills + // June 26-September 2, 1997 + const wstring str = L"12:00:00 06/26/97 Tuesday September 1997 Cindy Sherman"; + + // 01 get_time + wstring res1; + err = goodbit; + iter_type end1 = tg.get_time(str.begin(), str.end(), iss, err, &tm1); + wstring rem1(end1, str.end()); + VERIFY( err == goodbit ); + VERIFY( tm1.tm_sec == time_sanity.tm_sec ); + VERIFY( tm1.tm_min == time_sanity.tm_min ); + VERIFY( tm1.tm_hour == time_sanity.tm_hour ); + VERIFY( rem1 == L" 06/26/97 Tuesday September 1997 Cindy Sherman" ); +} + +int main() +{ + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_time/wchar_t/4.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_time/wchar_t/4.cc new file mode 100644 index 000000000..b3feb9eb5 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_time/wchar_t/4.cc @@ -0,0 +1,63 @@ +// 2004-08-29 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2004, 2005, 2006, 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +// Allow for one leap-second (two if !_GLIBCXX_USE_C99). +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef istreambuf_iterator<wchar_t> iterator_type; + + // basic construction and sanity checks. + locale loc_c = locale::classic(); + + // create an istream-derived object, cache the time_get facet + iterator_type end; + wistringstream iss; + iss.imbue(loc_c); + const time_get<wchar_t>& tim_get = + use_facet<time_get<wchar_t> >(iss.getloc()); + + const ios_base::iostate good = ios_base::goodbit; + ios_base::iostate errorstate = good; + + // create "C" time objects + const tm time_bday = __gnu_test::test_tm(60, 0, 12, 4, 3, 71, 0, 93, 0); + + iss.str(L"12:00:60 "); + iterator_type is_it01(iss); + tm time01; + errorstate = good; + tim_get.get_time(is_it01, end, iss, errorstate, &time01); + VERIFY( time01.tm_sec == time_bday.tm_sec ); + VERIFY( errorstate == ios_base::goodbit ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_time/wchar_t/5.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_time/wchar_t/5.cc new file mode 100644 index 000000000..ffce43218 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_time/wchar_t/5.cc @@ -0,0 +1,71 @@ +// 2006-06-16 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2006, 2009, 2010 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +// Check that the err argument is ignored by get_time. +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef wstring::const_iterator iter_type; + typedef time_get<wchar_t, iter_type> time_get_type; + const ios_base::iostate goodbit = ios_base::goodbit; + const ios_base::iostate eofbit = ios_base::eofbit; + const ios_base::iostate failbit = ios_base::failbit; + ios_base::iostate err = goodbit; + const locale loc_c = locale::classic(); + + // Create "C" time objects + const tm time_sanity = __gnu_test::test_tm(0, 0, 12, 26, 5, 97, 2, 0, 0); + tm tm0 = __gnu_test::test_tm(0, 0, 0, 0, 0, 0, 0, 0, 0); + tm tm1 = __gnu_test::test_tm(0, 0, 0, 0, 0, 0, 0, 0, 0); + + wistringstream iss; + iss.imbue(locale(loc_c, new time_get_type)); + + // Iterator advanced, state, output. + const time_get_type& tg = use_facet<time_get_type>(iss.getloc()); + + const wstring str0 = L"1"; + tg.get_time(str0.begin(), str0.end(), iss, err, &tm0); + VERIFY( err == (failbit | eofbit) ); + VERIFY( tm0.tm_sec == 0 ); + VERIFY( tm0.tm_min == 0 ); + VERIFY( tm0.tm_hour == 0 ); + + const wstring str1 = L"12:00:00 "; + iter_type end1 = tg.get_time(str1.begin(), str1.end(), iss, err, &tm1); + VERIFY( err == (failbit | eofbit) ); + VERIFY( tm1.tm_sec == time_sanity.tm_sec ); + VERIFY( tm1.tm_min == time_sanity.tm_min ); + VERIFY( tm1.tm_hour == time_sanity.tm_hour ); + VERIFY( *end1 == L' ' ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_time/wchar_t/6.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_time/wchar_t/6.cc new file mode 100644 index 000000000..f544422f1 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_time/wchar_t/6.cc @@ -0,0 +1,71 @@ +// 2010-10-07 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010 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 +// <http://www.gnu.org/licenses/>. + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef wstring::const_iterator iter_type; + typedef time_get<wchar_t, iter_type> time_get_type; + const ios_base::iostate goodbit = ios_base::goodbit; + const ios_base::iostate eofbit = ios_base::eofbit; + const ios_base::iostate failbit = ios_base::failbit; + ios_base::iostate err = goodbit; + const locale loc_c = locale::classic(); + + // Create "C" time objects + tm tm0 = __gnu_test::test_tm(0, 0, 0, 0, 0, 0, 0, 0, 0); + tm tm1 = __gnu_test::test_tm(0, 0, 0, 0, 0, 0, 0, 0, 0); + + wistringstream iss; + iss.imbue(locale(loc_c, new time_get_type)); + + // Iterator advanced, state, output. + const time_get_type& tg = use_facet<time_get_type>(iss.getloc()); + + const wstring str0 = L"12"; + tg.get_time(str0.begin(), str0.end(), iss, err, &tm0); + VERIFY( err == (failbit | eofbit) ); + VERIFY( tm0.tm_sec == 0 ); + VERIFY( tm0.tm_min == 0 ); + // This is quite hard to guarantee now, revisit together with DR 461 + // in the C++0x context. + // VERIFY( tm0.tm_hour == 0 ); + + const wstring str1 = L"12:30 "; + err = goodbit; + iter_type end1 = tg.get_time(str1.begin(), str1.end(), iss, err, &tm1); + VERIFY( err == failbit ); + VERIFY( *end1 == ' ' ); + VERIFY( tm1.tm_sec == 0 ); + // See above... + // VERIFY( tm1.tm_min == 0 ); + // VERIFY( tm1.tm_hour == 0 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_time/wchar_t/wrapped_env.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_time/wchar_t/wrapped_env.cc new file mode 100644 index 000000000..8f116717b --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_time/wchar_t/wrapped_env.cc @@ -0,0 +1,48 @@ +// { dg-require-namedlocale "de_DE" } +// { dg-require-namedlocale "en_HK" } + +// 2001-08-15 Benjamin Kosnik <bkoz@redhat.com> + +// 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.4.1.1 collate members + +#include <testsuite_hooks.h> + +#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 + +int main() +{ + using namespace __gnu_test; + func_callback two; + two.push_back(&test01); + two.push_back(&test02); + two.push_back(&test03); + run_tests_wrapped_env("de_DE", "LANG", two); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_time/wchar_t/wrapped_locale.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_time/wchar_t/wrapped_locale.cc new file mode 100644 index 000000000..a4edc45a8 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_time/wchar_t/wrapped_locale.cc @@ -0,0 +1,49 @@ +// { dg-require-namedlocale "ja_JP.eucjp" } +// { dg-require-namedlocale "de_DE" } +// { dg-require-namedlocale "en_HK" } + +// 2001-08-15 Benjamin Kosnik <bkoz@redhat.com> + +// 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.4.1.1 collate members + +#include <testsuite_hooks.h> + +#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 + +int main() +{ + using namespace __gnu_test; + func_callback two; + two.push_back(&test01); + two.push_back(&test02); + two.push_back(&test03); + run_tests_wrapped_locale("ja_JP.eucjp", two); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/char/1.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/char/1.cc new file mode 100644 index 000000000..a7cef0ac5 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/char/1.cc @@ -0,0 +1,120 @@ +// 2001-09-21 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef istreambuf_iterator<char> iterator_type; + + // basic construction + locale loc_c = locale::classic(); + + const string empty; + + // create an ostream-derived object, cache the time_get facet + iterator_type end; + + istringstream iss; + iss.imbue(loc_c); + const time_get<char>& tim_get = use_facet<time_get<char> >(iss.getloc()); + + const ios_base::iostate good = ios_base::goodbit; + ios_base::iostate errorstate = good; + + // create "C" time objects + const tm time_bday = __gnu_test::test_tm(0, 0, 12, 4, 3, 71, 0, 93, 0); + + // iter_type + // get_weekday(iter_type, iter_type, ios_base&, + // ios_base::iostate&, tm*) const + + // sanity checks for "C" locale + iss.str("Sunday"); + iterator_type is_it01(iss); + tm time01; + errorstate = good; + tim_get.get_weekday(is_it01, end, iss, errorstate, &time01); + VERIFY( time01.tm_wday == time_bday.tm_wday ); + VERIFY( errorstate == ios_base::eofbit ); + + iss.str("Sun"); + iterator_type is_it02(iss); + tm time02; + errorstate = good; + tim_get.get_weekday(is_it02, end, iss, errorstate, &time02); + VERIFY( time02.tm_wday == time_bday.tm_wday ); + VERIFY( errorstate == ios_base::eofbit ); + + iss.str("Sun "); + iterator_type is_it03(iss); + tm time03; + errorstate = good; + iterator_type ret03 = tim_get.get_weekday(is_it03, end, iss, errorstate, + &time03); + VERIFY( time03.tm_wday == time_bday.tm_wday ); + VERIFY( errorstate == good ); + VERIFY( *ret03 == ' ' ); + + iss.str("San"); + iterator_type is_it04(iss); + tm time04; + time04.tm_wday = 4; + errorstate = good; + iterator_type ret04 = tim_get.get_weekday(is_it04, end, iss, errorstate, + &time04); + VERIFY( time04.tm_wday == 4 ); + VERIFY( *ret04 == 'n' ); + VERIFY( errorstate == ios_base::failbit ); + + iss.str("Tuesday "); + iterator_type is_it05(iss); + tm time05; + errorstate = good; + iterator_type ret05 = tim_get.get_weekday(is_it05, end, iss, errorstate, + &time05); + VERIFY( time05.tm_wday == 2 ); + VERIFY( errorstate == good ); + VERIFY( *ret05 == ' ' ); + + iss.str("Tuesducky "); // Kind of like Fryday, without the swirls. + iterator_type is_it06(iss); + tm time06; + time06.tm_wday = 4; + errorstate = good; + iterator_type ret06 = tim_get.get_weekday(is_it06, end, iss, errorstate, + &time06); + VERIFY( time06.tm_wday == 4 ); + VERIFY( errorstate == ios_base::failbit ); + VERIFY( *ret06 == 'u' ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/char/2.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/char/2.cc new file mode 100644 index 000000000..1b1136987 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/char/2.cc @@ -0,0 +1,83 @@ +// { dg-require-namedlocale "en_HK" } +// { dg-require-namedlocale "de_DE" } + +// 2001-09-21 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +void test02() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef istreambuf_iterator<char> iterator_type; + + // basic construction and sanity checks. + locale loc_c = locale::classic(); + locale loc_hk = locale("en_HK"); + locale loc_de = locale("de_DE"); + VERIFY( loc_hk != loc_c ); + VERIFY( loc_hk != loc_de ); + + const string empty; + + // create an ostream-derived object, cache the time_get facet + iterator_type end; + + istringstream iss; + const time_get<char>& tim_get = use_facet<time_get<char> >(iss.getloc()); + + const ios_base::iostate good = ios_base::goodbit; + ios_base::iostate errorstate = good; + + // create "C" time objects + const tm time_bday = __gnu_test::test_tm(0, 0, 12, 4, 3, 71, 0, 93, 0); + + // inspection of named locales, de_DE + iss.imbue(loc_de); + iss.str("Sonntag"); + iterator_type is_it10(iss); + tm time10; + errorstate = good; + tim_get.get_weekday(is_it10, end, iss, errorstate, &time10); + VERIFY( time10.tm_wday == time_bday.tm_wday ); + VERIFY( errorstate == ios_base::eofbit ); + + // inspection of named locales, en_HK + iss.imbue(loc_hk); + iss.str("Sunday"); + iterator_type is_it20(iss); + tm time20; + errorstate = good; + tim_get.get_weekday(is_it20, end, iss, errorstate, &time20); + VERIFY( time20.tm_wday == time_bday.tm_wday ); + VERIFY( errorstate == ios_base::eofbit ); +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/char/3.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/char/3.cc new file mode 100644 index 000000000..6e4d188d5 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/char/3.cc @@ -0,0 +1,69 @@ +// 2001-09-21 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +void test03() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + // Check time_get works with other iterators besides streambuf + // input iterators. + typedef string::const_iterator iter_type; + typedef time_get<char, iter_type> time_get_type; + const ios_base::iostate goodbit = ios_base::goodbit; + ios_base::iostate err = goodbit; + const locale loc_c = locale::classic(); + + // Create "C" time objects + const tm time_sanity = __gnu_test::test_tm(0, 0, 12, 26, 5, 97, 2, 0, 0); + tm tm1; + + istringstream iss; + iss.imbue(locale(loc_c, new time_get_type)); + + // Iterator advanced, state, output. + const time_get_type& tg = use_facet<time_get_type>(iss.getloc()); + + // Cindy Sherman's Untitled Film Stills + // June 26-September 2, 1997 + const string str = "Tuesday September 1997 Cindy Sherman"; + + // 03 get_weekday + string res3; + err = goodbit; + // White space is not eaten, so manually increment past it. + iter_type end3 = tg.get_weekday(str.begin(), str.end(), iss, err, &tm1); + string rem3(end3, str.end()); + VERIFY( err == goodbit ); + VERIFY( tm1.tm_wday == time_sanity.tm_wday ); + VERIFY( rem3 == " September 1997 Cindy Sherman" ); +} + +int main() +{ + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/char/38081-1.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/char/38081-1.cc new file mode 100644 index 000000000..4e039775a --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/char/38081-1.cc @@ -0,0 +1,94 @@ +// { dg-require-namedlocale "ru_RU.ISO-8859-5" } + +// Copyright (C) 2010, 2011 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <cstring> +#include <testsuite_hooks.h> + +// libstdc++/38081 +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef istreambuf_iterator<char> iterator_type; + + // basic construction + locale loc("ru_RU.ISO-8859-5"); + + // create an ostream-derived object, cache the time_get facet + iterator_type end; + + istringstream iss; + iss.imbue(loc); + const time_get<char>& tim_get = use_facet<time_get<char> >(iss.getloc()); + + const ios_base::iostate good = ios_base::goodbit; + ios_base::iostate errorstate = good; + + // iter_type + // get_weekday(iter_type, iter_type, ios_base&, + // ios_base::iostate&, tm*) const + +#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 14) + iss.str("\xbf\xdd\x2e"); +#else + iss.str("\xbf\xdd\xd4"); +#endif + iterator_type is_it01(iss); + tm time01; + memset(&time01, -1, sizeof(tm)); + errorstate = good; + tim_get.get_weekday(is_it01, end, iss, errorstate, &time01); + VERIFY( time01.tm_wday == 1 ); + VERIFY( errorstate == ios_base::eofbit ); + + iss.str("\xbf\xde\xdd\xd5\xd4\xd5\xdb\xec\xdd\xd8\xda"); + iterator_type is_it02(iss); + tm time02; + memset(&time02, -1, sizeof(tm)); + errorstate = good; + tim_get.get_weekday(is_it02, end, iss, errorstate, &time02); + VERIFY( time02.tm_wday == 1 ); + VERIFY( errorstate == ios_base::eofbit ); + +#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 14) + iss.str("\xbf\xdd\x2e\xd5\xd4\xd5\xdb\xec\xdd\xd8\xda"); +#else + iss.str("\xbf\xdd\xd4\xd5\xd4\xd5\xdb\xec\xdd\xd8\xda"); +#endif + iterator_type is_it03(iss); + tm time03; + memset(&time03, -1, sizeof(tm)); + errorstate = good; + iterator_type ret = tim_get.get_weekday(is_it03, end, iss, + errorstate, &time03); + VERIFY( time03.tm_wday == 1 ); + VERIFY( errorstate == ios_base::goodbit ); + VERIFY( *ret == '\xd5' ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/char/38081-2.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/char/38081-2.cc new file mode 100644 index 000000000..ee8d6769d --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/char/38081-2.cc @@ -0,0 +1,110 @@ +// { dg-require-namedlocale "ru_RU.UTF8" } + +// 2010-01-05 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010, 2011 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <cstring> +#include <testsuite_hooks.h> + +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef istreambuf_iterator<char> iterator_type; + + // basic construction + locale loc("ru_RU.UTF8"); + + // create an ostream-derived object, cache the time_get facet + iterator_type end; + + istringstream iss; + iss.imbue(loc); + const time_get<char>& tim_get = use_facet<time_get<char> >(iss.getloc()); + + const ios_base::iostate good = ios_base::goodbit; + ios_base::iostate errorstate = good; + + // iter_type + // get_weekday(iter_type, iter_type, ios_base&, + // ios_base::iostate&, tm*) const + +#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 14) + const char* awdays[7] = { "\u0412\u0441\u002E", + "\u041F\u043D\u002E", + "\u0412\u0442\u002E", + "\u0421\u0440\u002E", + "\u0427\u0442\u002E", + "\u041F\u0442\u002E", + "\u0421\u0431\u002E" }; +#else + const char* awdays[7] = { "\u0412\u0441\u043A", + "\u041F\u043D\u0434", + "\u0412\u0442\u0440", + "\u0421\u0440\u0434", + "\u0427\u0442\u0432", + "\u041F\u0442\u043D", + "\u0421\u0431\u0442" }; +#endif + + for (int i = 0; i < 7; ++i) + { + iss.str(awdays[i]); + iterator_type is_it01(iss); + tm time01; + memset(&time01, -1, sizeof(tm)); + errorstate = good; + tim_get.get_weekday(is_it01, end, iss, errorstate, &time01); + VERIFY( time01.tm_wday == i ); + VERIFY( errorstate == ios_base::eofbit ); + } + + const char* wdays[7] = { "\u0412\u043E\u0441\u043A\u0440\u0435" + "\u0441\u0435\u043D\u044C\u0435", + "\u041F\u043E\u043D\u0435\u0434\u0435" + "\u043B\u044C\u043D\u0438\u043A", + "\u0412\u0442\u043E\u0440\u043D\u0438\u043A", + "\u0421\u0440\u0435\u0434\u0430", + "\u0427\u0435\u0442\u0432\u0435\u0440\u0433", + "\u041F\u044F\u0442\u043D\u0438\u0446\u0430", + "\u0421\u0443\u0431\u0431\u043E\u0442\u0430" }; + + for (int i = 0; i < 7; ++i) + { + iss.str(wdays[i]); + iterator_type is_it01(iss); + tm time01; + memset(&time01, -1, sizeof(tm)); + errorstate = good; + tim_get.get_weekday(is_it01, end, iss, errorstate, &time01); + VERIFY( time01.tm_wday == i ); + VERIFY( errorstate == ios_base::eofbit ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/char/5.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/char/5.cc new file mode 100644 index 000000000..4157a08b5 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/char/5.cc @@ -0,0 +1,67 @@ +// 2006-06-16 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2006, 2009, 2010 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +// Check that the err argument is ignored by get_weekday. +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef string::const_iterator iter_type; + typedef time_get<char, iter_type> time_get_type; + const ios_base::iostate goodbit = ios_base::goodbit; + const ios_base::iostate eofbit = ios_base::eofbit; + const ios_base::iostate failbit = ios_base::failbit; + ios_base::iostate err = goodbit; + const locale loc_c = locale::classic(); + + // Create "C" time objects + const tm time_sanity = __gnu_test::test_tm(0, 0, 12, 26, 5, 97, 2, 0, 0); + tm tm0 = __gnu_test::test_tm(0, 0, 0, 0, 0, 0, 0, 0, 0); + tm tm1 = __gnu_test::test_tm(0, 0, 0, 0, 0, 0, 0, 0, 0); + + istringstream iss; + iss.imbue(locale(loc_c, new time_get_type)); + + // Iterator advanced, state, output. + const time_get_type& tg = use_facet<time_get_type>(iss.getloc()); + + const string str0 = "T"; + tg.get_weekday(str0.begin(), str0.end(), iss, err, &tm0); + VERIFY( err == (failbit | eofbit) ); + VERIFY( tm1.tm_wday == 0 ); + + const string str1 = "Tuesday "; + iter_type end1 = tg.get_weekday(str1.begin(), str1.end(), iss, err, &tm1); + VERIFY( err == (failbit | eofbit) ); + VERIFY( tm1.tm_wday == time_sanity.tm_wday ); + VERIFY( *end1 == ' ' ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/char/6.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/char/6.cc new file mode 100644 index 000000000..1d28dbf3c --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/char/6.cc @@ -0,0 +1,87 @@ +// 2010-01-05 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <cstring> +#include <testsuite_hooks.h> + +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef istreambuf_iterator<char> iterator_type; + + // basic construction + locale loc_c = locale::classic(); + + // create an ostream-derived object, cache the time_get facet + iterator_type end; + + istringstream iss; + iss.imbue(loc_c); + const time_get<char>& tim_get = use_facet<time_get<char> >(iss.getloc()); + + const ios_base::iostate good = ios_base::goodbit; + ios_base::iostate errorstate = good; + + // iter_type + // get_weekday(iter_type, iter_type, ios_base&, + // ios_base::iostate&, tm*) const + + // sanity checks for "C" locale + + const char* awdays[7] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; + + for (int i = 0; i < 7; ++i) + { + iss.str(awdays[i]); + iterator_type is_it01(iss); + tm time01; + memset(&time01, -1, sizeof(tm)); + errorstate = good; + tim_get.get_weekday(is_it01, end, iss, errorstate, &time01); + VERIFY( time01.tm_wday == i ); + VERIFY( errorstate == ios_base::eofbit ); + } + + const char* wdays[7] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", + "Friday", "Saturday" }; + + for (int i = 0; i < 7; ++i) + { + iss.str(wdays[i]); + iterator_type is_it01(iss); + tm time01; + memset(&time01, -1, sizeof(tm)); + errorstate = good; + tim_get.get_weekday(is_it01, end, iss, errorstate, &time01); + VERIFY( time01.tm_wday == i ); + VERIFY( errorstate == ios_base::eofbit ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/char/wrapped_env.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/char/wrapped_env.cc new file mode 100644 index 000000000..8f116717b --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/char/wrapped_env.cc @@ -0,0 +1,48 @@ +// { dg-require-namedlocale "de_DE" } +// { dg-require-namedlocale "en_HK" } + +// 2001-08-15 Benjamin Kosnik <bkoz@redhat.com> + +// 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.4.1.1 collate members + +#include <testsuite_hooks.h> + +#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 + +int main() +{ + using namespace __gnu_test; + func_callback two; + two.push_back(&test01); + two.push_back(&test02); + two.push_back(&test03); + run_tests_wrapped_env("de_DE", "LANG", two); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/char/wrapped_locale.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/char/wrapped_locale.cc new file mode 100644 index 000000000..a4edc45a8 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/char/wrapped_locale.cc @@ -0,0 +1,49 @@ +// { dg-require-namedlocale "ja_JP.eucjp" } +// { dg-require-namedlocale "de_DE" } +// { dg-require-namedlocale "en_HK" } + +// 2001-08-15 Benjamin Kosnik <bkoz@redhat.com> + +// 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.4.1.1 collate members + +#include <testsuite_hooks.h> + +#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 + +int main() +{ + using namespace __gnu_test; + func_callback two; + two.push_back(&test01); + two.push_back(&test02); + two.push_back(&test03); + run_tests_wrapped_locale("ja_JP.eucjp", two); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/wchar_t/1.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/wchar_t/1.cc new file mode 100644 index 000000000..46aa684f8 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/wchar_t/1.cc @@ -0,0 +1,120 @@ +// 2001-09-21 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef istreambuf_iterator<wchar_t> iterator_type; + + // basic construction + locale loc_c = locale::classic(); + + const wstring empty; + + // create an ostream-derived object, cache the time_get facet + iterator_type end; + + wistringstream iss; + iss.imbue(loc_c); + const time_get<wchar_t>& tim_get = use_facet<time_get<wchar_t> >(iss.getloc()); + + const ios_base::iostate good = ios_base::goodbit; + ios_base::iostate errorstate = good; + + // create "C" time objects + const tm time_bday = __gnu_test::test_tm(0, 0, 12, 4, 3, 71, 0, 93, 0); + + // iter_type + // get_weekday(iter_type, iter_type, ios_base&, + // ios_base::iostate&, tm*) const + + // sanity checks for "C" locale + iss.str(L"Sunday"); + iterator_type is_it01(iss); + tm time01; + errorstate = good; + tim_get.get_weekday(is_it01, end, iss, errorstate, &time01); + VERIFY( time01.tm_wday == time_bday.tm_wday ); + VERIFY( errorstate == ios_base::eofbit ); + + iss.str(L"Sun"); + iterator_type is_it02(iss); + tm time02; + errorstate = good; + tim_get.get_weekday(is_it02, end, iss, errorstate, &time02); + VERIFY( time02.tm_wday == time_bday.tm_wday ); + VERIFY( errorstate == ios_base::eofbit ); + + iss.str(L"Sun "); + iterator_type is_it03(iss); + tm time03; + errorstate = good; + iterator_type ret03 = tim_get.get_weekday(is_it03, end, iss, errorstate, + &time03); + VERIFY( time03.tm_wday == time_bday.tm_wday ); + VERIFY( errorstate == good ); + VERIFY( *ret03 == L' ' ); + + iss.str(L"San"); + iterator_type is_it04(iss); + tm time04; + time04.tm_wday = 4; + errorstate = good; + iterator_type ret04 = tim_get.get_weekday(is_it04, end, iss, errorstate, + &time04); + VERIFY( time04.tm_wday == 4 ); + VERIFY( *ret04 == L'n' ); + VERIFY( errorstate == ios_base::failbit ); + + iss.str(L"Tuesday "); + iterator_type is_it05(iss); + tm time05; + errorstate = good; + iterator_type ret05 = tim_get.get_weekday(is_it05, end, iss, errorstate, + &time05); + VERIFY( time05.tm_wday == 2 ); + VERIFY( errorstate == good ); + VERIFY( *ret05 == L' ' ); + + iss.str(L"Tuesducky "); // Kind of like Fryday, without the swirls. + iterator_type is_it06(iss); + tm time06; + time06.tm_wday = 4; + errorstate = good; + iterator_type ret06 = tim_get.get_weekday(is_it06, end, iss, errorstate, + &time06); + VERIFY( time06.tm_wday == 4 ); + VERIFY( errorstate == ios_base::failbit ); + VERIFY( *ret06 == L'u' ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/wchar_t/2.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/wchar_t/2.cc new file mode 100644 index 000000000..dbab614d1 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/wchar_t/2.cc @@ -0,0 +1,83 @@ +// { dg-require-namedlocale "en_HK" } +// { dg-require-namedlocale "de_DE" } + +// 2001-09-21 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +void test02() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef istreambuf_iterator<wchar_t> iterator_type; + + // basic construction and sanity checks. + locale loc_c = locale::classic(); + locale loc_hk = locale("en_HK"); + locale loc_de = locale("de_DE"); + VERIFY( loc_hk != loc_c ); + VERIFY( loc_hk != loc_de ); + + const wstring empty; + + // create an ostream-derived object, cache the time_get facet + iterator_type end; + + wistringstream iss; + const time_get<wchar_t>& tim_get = use_facet<time_get<wchar_t> >(iss.getloc()); + + const ios_base::iostate good = ios_base::goodbit; + ios_base::iostate errorstate = good; + + // create "C" time objects + const tm time_bday = __gnu_test::test_tm(0, 0, 12, 4, 3, 71, 0, 93, 0); + + // inspection of named locales, de_DE + iss.imbue(loc_de); + iss.str(L"Sonntag"); + iterator_type is_it10(iss); + tm time10; + errorstate = good; + tim_get.get_weekday(is_it10, end, iss, errorstate, &time10); + VERIFY( time10.tm_wday == time_bday.tm_wday ); + VERIFY( errorstate == ios_base::eofbit ); + + // inspection of named locales, en_HK + iss.imbue(loc_hk); + iss.str(L"Sunday"); + iterator_type is_it20(iss); + tm time20; + errorstate = good; + tim_get.get_weekday(is_it20, end, iss, errorstate, &time20); + VERIFY( time20.tm_wday == time_bday.tm_wday ); + VERIFY( errorstate == ios_base::eofbit ); +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/wchar_t/3.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/wchar_t/3.cc new file mode 100644 index 000000000..d1f982fe6 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/wchar_t/3.cc @@ -0,0 +1,69 @@ +// 2001-09-21 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +void test03() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + // Check time_get works with other iterators besides streambuf + // input iterators. + typedef wstring::const_iterator iter_type; + typedef time_get<wchar_t, iter_type> time_get_type; + const ios_base::iostate goodbit = ios_base::goodbit; + ios_base::iostate err = goodbit; + const locale loc_c = locale::classic(); + + // Create "C" time objects + const tm time_sanity = __gnu_test::test_tm(0, 0, 12, 26, 5, 97, 2, 0, 0); + tm tm1; + + wistringstream iss; + iss.imbue(locale(loc_c, new time_get_type)); + + // Iterator advanced, state, output. + const time_get_type& tg = use_facet<time_get_type>(iss.getloc()); + + // Cindy Sherman's Untitled Film Stills + // June 26-September 2, 1997 + const wstring str = L"Tuesday September 1997 Cindy Sherman"; + + // 03 get_weekday + wstring res3; + err = goodbit; + // White space is not eaten, so manually increment past it. + iter_type end3 = tg.get_weekday(str.begin(), str.end(), iss, err, &tm1); + wstring rem3(end3, str.end()); + VERIFY( err == goodbit ); + VERIFY( tm1.tm_wday == time_sanity.tm_wday ); + VERIFY( rem3 == L" September 1997 Cindy Sherman" ); +} + +int main() +{ + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/wchar_t/5.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/wchar_t/5.cc new file mode 100644 index 000000000..02664bf0b --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/wchar_t/5.cc @@ -0,0 +1,67 @@ +// 2006-06-16 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2006, 2009, 2010 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +// Check that the err argument is ignored by get_weekday. +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef wstring::const_iterator iter_type; + typedef time_get<wchar_t, iter_type> time_get_type; + const ios_base::iostate goodbit = ios_base::goodbit; + const ios_base::iostate eofbit = ios_base::eofbit; + const ios_base::iostate failbit = ios_base::failbit; + ios_base::iostate err = goodbit; + const locale loc_c = locale::classic(); + + // Create "C" time objects + const tm time_sanity = __gnu_test::test_tm(0, 0, 12, 26, 5, 97, 2, 0, 0); + tm tm0 = __gnu_test::test_tm(0, 0, 0, 0, 0, 0, 0, 0, 0); + tm tm1 = __gnu_test::test_tm(0, 0, 0, 0, 0, 0, 0, 0, 0); + + wistringstream iss; + iss.imbue(locale(loc_c, new time_get_type)); + + // Iterator advanced, state, output. + const time_get_type& tg = use_facet<time_get_type>(iss.getloc()); + + const wstring str0 = L"T"; + tg.get_weekday(str0.begin(), str0.end(), iss, err, &tm0); + VERIFY( err == (failbit | eofbit) ); + VERIFY( tm1.tm_wday == 0 ); + + const wstring str1 = L"Tuesday "; + iter_type end1 = tg.get_weekday(str1.begin(), str1.end(), iss, err, &tm1); + VERIFY( err == (failbit | eofbit) ); + VERIFY( tm1.tm_wday == time_sanity.tm_wday ); + VERIFY( *end1 == L' ' ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/wchar_t/6.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/wchar_t/6.cc new file mode 100644 index 000000000..39a3e3dec --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/wchar_t/6.cc @@ -0,0 +1,89 @@ +// 2010-01-05 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <cstring> +#include <testsuite_hooks.h> + +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef istreambuf_iterator<wchar_t> iterator_type; + + // basic construction + locale loc_c = locale::classic(); + + // create an ostream-derived object, cache the time_get facet + iterator_type end; + + wistringstream iss; + iss.imbue(loc_c); + const time_get<wchar_t>& tim_get + = use_facet<time_get<wchar_t> >(iss.getloc()); + + const ios_base::iostate good = ios_base::goodbit; + ios_base::iostate errorstate = good; + + // iter_type + // get_weekday(iter_type, iter_type, ios_base&, + // ios_base::iostate&, tm*) const + + // sanity checks for "C" locale + + const wchar_t* awdays[7] = { L"Sun", L"Mon", L"Tue", L"Wed", + L"Thu", L"Fri", L"Sat" }; + + for (int i = 0; i < 7; ++i) + { + iss.str(awdays[i]); + iterator_type is_it01(iss); + tm time01; + memset(&time01, -1, sizeof(tm)); + errorstate = good; + tim_get.get_weekday(is_it01, end, iss, errorstate, &time01); + VERIFY( time01.tm_wday == i ); + VERIFY( errorstate == ios_base::eofbit ); + } + + const wchar_t* wdays[7] = { L"Sunday", L"Monday", L"Tuesday", L"Wednesday", + L"Thursday", L"Friday", L"Saturday" }; + + for (int i = 0; i < 7; ++i) + { + iss.str(wdays[i]); + iterator_type is_it01(iss); + tm time01; + memset(&time01, -1, sizeof(tm)); + errorstate = good; + tim_get.get_weekday(is_it01, end, iss, errorstate, &time01); + VERIFY( time01.tm_wday == i ); + VERIFY( errorstate == ios_base::eofbit ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/wchar_t/wrapped_env.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/wchar_t/wrapped_env.cc new file mode 100644 index 000000000..bcd8f51d6 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/wchar_t/wrapped_env.cc @@ -0,0 +1,48 @@ +// { dg-require-namedlocale "en_HK" } +// { dg-require-namedlocale "de_DE" } + +// 2001-08-15 Benjamin Kosnik <bkoz@redhat.com> + +// 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.4.1.1 collate members + +#include <testsuite_hooks.h> + +#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 + +int main() +{ + using namespace __gnu_test; + func_callback two; + two.push_back(&test01); + two.push_back(&test02); + two.push_back(&test03); + run_tests_wrapped_env("de_DE", "LANG", two); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/wchar_t/wrapped_locale.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/wchar_t/wrapped_locale.cc new file mode 100644 index 000000000..610c7dbf2 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/wchar_t/wrapped_locale.cc @@ -0,0 +1,49 @@ +// { dg-require-namedlocale "en_HK" } +// { dg-require-namedlocale "de_DE" } +// { dg-require-namedlocale "ja_JP.eucjp" } + +// 2001-08-15 Benjamin Kosnik <bkoz@redhat.com> + +// 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.4.1.1 collate members + +#include <testsuite_hooks.h> + +#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 + +int main() +{ + using namespace __gnu_test; + func_callback two; + two.push_back(&test01); + two.push_back(&test02); + two.push_back(&test03); + run_tests_wrapped_locale("ja_JP.eucjp", two); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_year/char/1.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_year/char/1.cc new file mode 100644 index 000000000..c6fb3dda6 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_year/char/1.cc @@ -0,0 +1,108 @@ +// 2001-09-21 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef istreambuf_iterator<char> iterator_type; + + // basic construction + locale loc_c = locale::classic(); + + const string empty; + + // create an ostream-derived object, cache the time_get facet + iterator_type end; + + istringstream iss; + iss.imbue(loc_c); + const time_get<char>& tim_get = use_facet<time_get<char> >(iss.getloc()); + + const ios_base::iostate good = ios_base::goodbit; + ios_base::iostate errorstate = good; + + // create "C" time objects + const tm time_bday = __gnu_test::test_tm(0, 0, 12, 4, 3, 71, 0, 93, 0); + + // iter_type + // get_year(iter_type, iter_type, ios_base&, ios_base::iostate&, tm*) const + + // sanity checks for "C" locale + iss.str("1971"); + iterator_type is_it01(iss); + tm time01; + errorstate = good; + tim_get.get_year(is_it01, end, iss, errorstate, &time01); + VERIFY( time01.tm_year == time_bday.tm_year ); + VERIFY( errorstate == ios_base::eofbit ); + + iss.str("1971 "); + iterator_type is_it02(iss); + tm time02; + errorstate = good; + iterator_type ret02 = tim_get.get_year(is_it02, end, iss, errorstate, + &time02); + VERIFY( time02.tm_year == time_bday.tm_year ); + VERIFY( errorstate == good ); + VERIFY( *ret02 == ' ' ); + + iss.str("197d1 "); + iterator_type is_it03(iss); + tm time03; + time03.tm_year = 3; + errorstate = good; + iterator_type ret03 = tim_get.get_year(is_it03, end, iss, errorstate, + &time03); + VERIFY( time03.tm_year == 3 ); + VERIFY( errorstate == ios_base::failbit ); + VERIFY( *ret03 == 'd' ); + + iss.str("71d71"); + iterator_type is_it04(iss); + tm time04; + errorstate = good; + iterator_type ret04 = tim_get.get_year(is_it04, end, iss, errorstate, + &time04); + VERIFY( time04.tm_year == time_bday.tm_year ); + VERIFY( errorstate == good ); + VERIFY( *ret04 == 'd' ); + + iss.str("71"); + iterator_type is_it05(iss); + tm time05; + errorstate = good; + tim_get.get_year(is_it05, end, iss, errorstate, &time05); + VERIFY( time05.tm_year == time_bday.tm_year ); + VERIFY( errorstate == ios_base::eofbit ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_year/char/3.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_year/char/3.cc new file mode 100644 index 000000000..e3d1f996d --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_year/char/3.cc @@ -0,0 +1,69 @@ +// 2001-09-21 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +void test03() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + // Check time_get works with other iterators besides streambuf + // input iterators. + typedef string::const_iterator iter_type; + typedef time_get<char, iter_type> time_get_type; + const ios_base::iostate goodbit = ios_base::goodbit; + ios_base::iostate err = goodbit; + const locale loc_c = locale::classic(); + + // Create "C" time objects + const tm time_sanity = __gnu_test::test_tm(0, 0, 12, 26, 5, 97, 2, 0, 0); + tm tm1; + + istringstream iss; + iss.imbue(locale(loc_c, new time_get_type)); + + // Iterator advanced, state, output. + const time_get_type& tg = use_facet<time_get_type>(iss.getloc()); + + // Cindy Sherman's Untitled Film Stills + // June 26-September 2, 1997 + const string str = "1997 Cindy Sherman"; + + // 05 get_year + string res5; + err = goodbit; + // White space is not eaten, so manually increment past it. + iter_type end5 = tg.get_year(str.begin(), str.end(), iss, err, &tm1); + string rem5(end5, str.end()); + VERIFY( err == goodbit ); + VERIFY( tm1.tm_year == time_sanity.tm_year ); + VERIFY( rem5 == " Cindy Sherman" ); +} + +int main() +{ + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_year/char/5.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_year/char/5.cc new file mode 100644 index 000000000..f3a47bf87 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_year/char/5.cc @@ -0,0 +1,67 @@ +// 2006-06-16 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2006, 2009, 2010 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +// Check that the err argument is ignored by get_year. +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef string::const_iterator iter_type; + typedef time_get<char, iter_type> time_get_type; + const ios_base::iostate goodbit = ios_base::goodbit; + const ios_base::iostate eofbit = ios_base::eofbit; + const ios_base::iostate failbit = ios_base::failbit; + ios_base::iostate err = goodbit; + const locale loc_c = locale::classic(); + + // Create "C" time objects + const tm time_sanity = __gnu_test::test_tm(0, 0, 12, 26, 5, 97, 2, 0, 0); + tm tm0 = __gnu_test::test_tm(0, 0, 0, 0, 0, 0, 0, 0, 0); + tm tm1 = __gnu_test::test_tm(0, 0, 0, 0, 0, 0, 0, 0, 0); + + istringstream iss; + iss.imbue(locale(loc_c, new time_get_type)); + + // Iterator advanced, state, output. + const time_get_type& tg = use_facet<time_get_type>(iss.getloc()); + + const string str0 = "1"; + tg.get_year(str0.begin(), str0.end(), iss, err, &tm0); + VERIFY( err == (failbit | eofbit) ); + VERIFY( tm0.tm_year == 0 ); + + const string str1 = "1997 "; + iter_type end1 = tg.get_year(str1.begin(), str1.end(), iss, err, &tm1); + VERIFY( err == (failbit | eofbit) ); + VERIFY( tm1.tm_year == time_sanity.tm_year ); + VERIFY( *end1 == ' ' ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_year/char/wrapped_env.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_year/char/wrapped_env.cc new file mode 100644 index 000000000..872603ace --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_year/char/wrapped_env.cc @@ -0,0 +1,42 @@ +// { dg-require-namedlocale "de_DE" } + +// 2001-08-15 Benjamin Kosnik <bkoz@redhat.com> + +// 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.4.1.1 collate members + +#include <testsuite_hooks.h> + +#define main discard_main_1 +#include "1.cc" +#undef main + +#define main discard_main_3 +#include "3.cc" +#undef main + +int main() +{ + using namespace __gnu_test; + func_callback two; + two.push_back(&test01); + two.push_back(&test03); + run_tests_wrapped_env("de_DE", "LANG", two); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_year/char/wrapped_locale.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_year/char/wrapped_locale.cc new file mode 100644 index 000000000..45dda12bd --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_year/char/wrapped_locale.cc @@ -0,0 +1,42 @@ +// { dg-require-namedlocale "ja_JP.eucjp" } + +// 2001-08-15 Benjamin Kosnik <bkoz@redhat.com> + +// 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.4.1.1 collate members + +#include <testsuite_hooks.h> + +#define main discard_main_1 +#include "1.cc" +#undef main + +#define main discard_main_3 +#include "3.cc" +#undef main + +int main() +{ + using namespace __gnu_test; + func_callback two; + two.push_back(&test01); + two.push_back(&test03); + run_tests_wrapped_locale("ja_JP.eucjp", two); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_year/wchar_t/1.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_year/wchar_t/1.cc new file mode 100644 index 000000000..69a86cf04 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_year/wchar_t/1.cc @@ -0,0 +1,108 @@ +// 2001-09-21 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef istreambuf_iterator<wchar_t> iterator_type; + + // basic construction + locale loc_c = locale::classic(); + + const wstring empty; + + // create an ostream-derived object, cache the time_get facet + iterator_type end; + + wistringstream iss; + iss.imbue(loc_c); + const time_get<wchar_t>& tim_get = use_facet<time_get<wchar_t> >(iss.getloc()); + + const ios_base::iostate good = ios_base::goodbit; + ios_base::iostate errorstate = good; + + // create "C" time objects + const tm time_bday = __gnu_test::test_tm(0, 0, 12, 4, 3, 71, 0, 93, 0); + + // iter_type + // get_year(iter_type, iter_type, ios_base&, ios_base::iostate&, tm*) const + + // sanity checks for "C" locale + iss.str(L"1971"); + iterator_type is_it01(iss); + tm time01; + errorstate = good; + tim_get.get_year(is_it01, end, iss, errorstate, &time01); + VERIFY( time01.tm_year == time_bday.tm_year ); + VERIFY( errorstate == ios_base::eofbit ); + + iss.str(L"1971 "); + iterator_type is_it02(iss); + tm time02; + errorstate = good; + iterator_type ret02 = tim_get.get_year(is_it02, end, iss, errorstate, + &time02); + VERIFY( time02.tm_year == time_bday.tm_year ); + VERIFY( errorstate == good ); + VERIFY( *ret02 == L' ' ); + + iss.str(L"197d1 "); + iterator_type is_it03(iss); + tm time03; + time03.tm_year = 3; + errorstate = good; + iterator_type ret03 = tim_get.get_year(is_it03, end, iss, errorstate, + &time03); + VERIFY( time03.tm_year == 3 ); + VERIFY( errorstate == ios_base::failbit ); + VERIFY( *ret03 == L'd' ); + + iss.str(L"71d71"); + iterator_type is_it04(iss); + tm time04; + errorstate = good; + iterator_type ret04 = tim_get.get_year(is_it04, end, iss, errorstate, + &time04); + VERIFY( time04.tm_year == time_bday.tm_year ); + VERIFY( errorstate == good ); + VERIFY( *ret04 == L'd' ); + + iss.str(L"71"); + iterator_type is_it05(iss); + tm time05; + errorstate = good; + tim_get.get_year(is_it05, end, iss, errorstate, &time05); + VERIFY( time05.tm_year == time_bday.tm_year ); + VERIFY( errorstate == ios_base::eofbit ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_year/wchar_t/3.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_year/wchar_t/3.cc new file mode 100644 index 000000000..41e687422 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_year/wchar_t/3.cc @@ -0,0 +1,69 @@ +// 2001-09-21 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +void test03() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + // Check time_get works with other iterators besides streambuf + // input iterators. + typedef wstring::const_iterator iter_type; + typedef time_get<wchar_t, iter_type> time_get_type; + const ios_base::iostate goodbit = ios_base::goodbit; + ios_base::iostate err = goodbit; + const locale loc_c = locale::classic(); + + // Create "C" time objects + const tm time_sanity = __gnu_test::test_tm(0, 0, 12, 26, 5, 97, 2, 0, 0); + tm tm1; + + istringstream iss; + iss.imbue(locale(loc_c, new time_get_type)); + + // Iterator advanced, state, output. + const time_get_type& tg = use_facet<time_get_type>(iss.getloc()); + + // Cindy Sherman's Untitled Film Stills + // June 26-September 2, 1997 + const wstring str = L"1997 Cindy Sherman"; + + // 05 get_year + wstring res5; + err = goodbit; + // White space is not eaten, so manually increment past it. + iter_type end5 = tg.get_year(str.begin(), str.end(), iss, err, &tm1); + wstring rem5(end5, str.end()); + VERIFY( err == goodbit ); + VERIFY( tm1.tm_year == time_sanity.tm_year ); + VERIFY( rem5 == L" Cindy Sherman" ); +} + +int main() +{ + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_year/wchar_t/5.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_year/wchar_t/5.cc new file mode 100644 index 000000000..c932bebdb --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_year/wchar_t/5.cc @@ -0,0 +1,67 @@ +// 2006-06-16 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2006, 2009, 2010 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +// Check that the err argument is ignored by get_year. +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef wstring::const_iterator iter_type; + typedef time_get<wchar_t, iter_type> time_get_type; + const ios_base::iostate goodbit = ios_base::goodbit; + const ios_base::iostate eofbit = ios_base::eofbit; + const ios_base::iostate failbit = ios_base::failbit; + ios_base::iostate err = goodbit; + const locale loc_c = locale::classic(); + + // Create "C" time objects + const tm time_sanity = __gnu_test::test_tm(0, 0, 12, 26, 5, 97, 2, 0, 0); + tm tm0 = __gnu_test::test_tm(0, 0, 0, 0, 0, 0, 0, 0, 0); + tm tm1 = __gnu_test::test_tm(0, 0, 0, 0, 0, 0, 0, 0, 0); + + wistringstream iss; + iss.imbue(locale(loc_c, new time_get_type)); + + // Iterator advanced, state, output. + const time_get_type& tg = use_facet<time_get_type>(iss.getloc()); + + const wstring str0 = L"1"; + tg.get_year(str0.begin(), str0.end(), iss, err, &tm0); + VERIFY( err == (failbit | eofbit) ); + VERIFY( tm0.tm_year == 0 ); + + const wstring str1 = L"1997 "; + iter_type end1 = tg.get_year(str1.begin(), str1.end(), iss, err, &tm1); + VERIFY( err == (failbit | eofbit) ); + VERIFY( tm1.tm_year == time_sanity.tm_year ); + VERIFY( *end1 == L' ' ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_year/wchar_t/wrapped_env.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_year/wchar_t/wrapped_env.cc new file mode 100644 index 000000000..872603ace --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_year/wchar_t/wrapped_env.cc @@ -0,0 +1,42 @@ +// { dg-require-namedlocale "de_DE" } + +// 2001-08-15 Benjamin Kosnik <bkoz@redhat.com> + +// 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.4.1.1 collate members + +#include <testsuite_hooks.h> + +#define main discard_main_1 +#include "1.cc" +#undef main + +#define main discard_main_3 +#include "3.cc" +#undef main + +int main() +{ + using namespace __gnu_test; + func_callback two; + two.push_back(&test01); + two.push_back(&test03); + run_tests_wrapped_env("de_DE", "LANG", two); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_year/wchar_t/wrapped_locale.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_year/wchar_t/wrapped_locale.cc new file mode 100644 index 000000000..45dda12bd --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_year/wchar_t/wrapped_locale.cc @@ -0,0 +1,42 @@ +// { dg-require-namedlocale "ja_JP.eucjp" } + +// 2001-08-15 Benjamin Kosnik <bkoz@redhat.com> + +// 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.4.1.1 collate members + +#include <testsuite_hooks.h> + +#define main discard_main_1 +#include "1.cc" +#undef main + +#define main discard_main_3 +#include "3.cc" +#undef main + +int main() +{ + using namespace __gnu_test; + func_callback two; + two.push_back(&test01); + two.push_back(&test03); + run_tests_wrapped_locale("ja_JP.eucjp", two); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/requirements/base_classes.cc b/libstdc++-v3/testsuite/22_locale/time_get/requirements/base_classes.cc new file mode 100644 index 000000000..e584bcae5 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/requirements/base_classes.cc @@ -0,0 +1,34 @@ +// { dg-do compile } +// 2001-09-21 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001, 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1 Template class time_get + +#include <locale> + +void test01() +{ + // Check for required base class. + typedef std::time_get<char> test_type; + typedef std::locale::facet base_type1; + typedef std::time_base base_type2; + const test_type& obj = std::use_facet<test_type>(std::locale()); + const base_type1* base1 __attribute__((unused)) = &obj; + const base_type2* base2 __attribute__((unused)) = &obj; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/22_locale/time_get/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..71c3697be --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/requirements/explicit_instantiation.cc @@ -0,0 +1,26 @@ +// { dg-do compile } +// 2001-09-21 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001, 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1 Template class time_get + +#include <locale> + +// Should be able to instantiate this for other types besides char, wchar_t +template class std::time_get<unsigned char>; diff --git a/libstdc++-v3/testsuite/22_locale/time_get/requirements/typedefs.cc b/libstdc++-v3/testsuite/22_locale/time_get/requirements/typedefs.cc new file mode 100644 index 000000000..f7faa823f --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/requirements/typedefs.cc @@ -0,0 +1,31 @@ +// { dg-do compile } +// 2001-09-21 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001, 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 +// <http://www.gnu.org/licenses/>. + +// 22.2.5.1 Template class time_get + +#include <locale> + +void test01() +{ + // Check for required typedefs + typedef std::time_get<char> test_type; + typedef test_type::char_type char_type; + typedef test_type::iter_type iter_type; +} |