From e11b210a9c1b68c361a9f9f172a4d26e0d37ed87 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Fri, 16 Jun 2006 22:13:13 +0000 Subject: [PATCH] locale_facets.tcc (time_get<>::_M_extract_via_format): Ignore the value of the __err argument. 2006-06-17 Paolo Carlini * include/bits/locale_facets.tcc (time_get<>::_M_extract_via_format): Ignore the value of the __err argument. (time_get<>::do_get_weekday): Likewise. (time_get<>::do_get_monthname): Likewise. * testsuite/22_locale/time_get/get_year/wchar_t/5.cc: New. * testsuite/22_locale/time_get/get_year/char/5.cc: Likewise. * testsuite/22_locale/time_get/get_monthname/wchar_t/5.cc: Likewise. * testsuite/22_locale/time_get/get_monthname/char/5.cc: Likewise. * testsuite/22_locale/time_get/get_weekday/wchar_t/5.cc: Likewise. * testsuite/22_locale/time_get/get_weekday/char/5.cc: Likewise. * testsuite/22_locale/time_get/get_date/wchar_t/5.cc: Likewise. * testsuite/22_locale/time_get/get_date/char/5.cc: Likewise. * testsuite/22_locale/time_get/get_time/wchar_t/5.cc: Likewise. * testsuite/22_locale/time_get/get_time/char/5.cc: Likewise. From-SVN: r114728 --- libstdc++-v3/ChangeLog | 17 ++++ libstdc++-v3/include/bits/locale_facets.tcc | 97 +++++++++++++--------- .../22_locale/time_get/get_date/char/5.cc | 71 ++++++++++++++++ .../22_locale/time_get/get_date/wchar_t/5.cc | 71 ++++++++++++++++ .../22_locale/time_get/get_monthname/char/5.cc | 67 +++++++++++++++ .../22_locale/time_get/get_monthname/wchar_t/5.cc | 67 +++++++++++++++ .../22_locale/time_get/get_time/char/5.cc | 72 ++++++++++++++++ .../22_locale/time_get/get_time/wchar_t/5.cc | 72 ++++++++++++++++ .../22_locale/time_get/get_weekday/char/5.cc | 68 +++++++++++++++ .../22_locale/time_get/get_weekday/wchar_t/5.cc | 68 +++++++++++++++ .../22_locale/time_get/get_year/char/5.cc | 68 +++++++++++++++ .../22_locale/time_get/get_year/wchar_t/5.cc | 68 +++++++++++++++ 12 files changed, 765 insertions(+), 41 deletions(-) create mode 100644 libstdc++-v3/testsuite/22_locale/time_get/get_date/char/5.cc create mode 100644 libstdc++-v3/testsuite/22_locale/time_get/get_date/wchar_t/5.cc create mode 100644 libstdc++-v3/testsuite/22_locale/time_get/get_monthname/char/5.cc create mode 100644 libstdc++-v3/testsuite/22_locale/time_get/get_monthname/wchar_t/5.cc create mode 100644 libstdc++-v3/testsuite/22_locale/time_get/get_time/char/5.cc create mode 100644 libstdc++-v3/testsuite/22_locale/time_get/get_time/wchar_t/5.cc create mode 100644 libstdc++-v3/testsuite/22_locale/time_get/get_weekday/char/5.cc create mode 100644 libstdc++-v3/testsuite/22_locale/time_get/get_weekday/wchar_t/5.cc create mode 100644 libstdc++-v3/testsuite/22_locale/time_get/get_year/char/5.cc create mode 100644 libstdc++-v3/testsuite/22_locale/time_get/get_year/wchar_t/5.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index e45a51a..e3b3442 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,20 @@ +2006-06-17 Paolo Carlini + + * include/bits/locale_facets.tcc (time_get<>::_M_extract_via_format): + Ignore the value of the __err argument. + (time_get<>::do_get_weekday): Likewise. + (time_get<>::do_get_monthname): Likewise. + * testsuite/22_locale/time_get/get_year/wchar_t/5.cc: New. + * testsuite/22_locale/time_get/get_year/char/5.cc: Likewise. + * testsuite/22_locale/time_get/get_monthname/wchar_t/5.cc: Likewise. + * testsuite/22_locale/time_get/get_monthname/char/5.cc: Likewise. + * testsuite/22_locale/time_get/get_weekday/wchar_t/5.cc: Likewise. + * testsuite/22_locale/time_get/get_weekday/char/5.cc: Likewise. + * testsuite/22_locale/time_get/get_date/wchar_t/5.cc: Likewise. + * testsuite/22_locale/time_get/get_date/char/5.cc: Likewise. + * testsuite/22_locale/time_get/get_time/wchar_t/5.cc: Likewise. + * testsuite/22_locale/time_get/get_time/char/5.cc: Likewise. + 2006-06-15 Benjamin Kosnik * include/ext/pb_ds/detail/type_utils.hpp (numeric_traits): Add, diff --git a/libstdc++-v3/include/bits/locale_facets.tcc b/libstdc++-v3/include/bits/locale_facets.tcc index 485851e..fd9b0bd 100644 --- a/libstdc++-v3/include/bits/locale_facets.tcc +++ b/libstdc++-v3/include/bits/locale_facets.tcc @@ -1891,7 +1891,8 @@ _GLIBCXX_END_LDBL_NAMESPACE const ctype<_CharT>& __ctype = use_facet >(__loc); const size_t __len = char_traits<_CharT>::length(__format); - for (size_t __i = 0; __beg != __end && __i < __len && !__err; ++__i) + ios_base::iostate __tmperr = ios_base::goodbit; + for (size_t __i = 0; __beg != __end && __i < __len && !__tmperr; ++__i) { if (__ctype.narrow(__format[__i], 0) == '%') { @@ -1909,14 +1910,14 @@ _GLIBCXX_END_LDBL_NAMESPACE const char_type* __days1[7]; __tp._M_days_abbreviated(__days1); __beg = _M_extract_name(__beg, __end, __tm->tm_wday, __days1, - 7, __io, __err); + 7, __io, __tmperr); break; case 'A': // Weekday name [tm_wday]. const char_type* __days2[7]; __tp._M_days(__days2); __beg = _M_extract_name(__beg, __end, __tm->tm_wday, __days2, - 7, __io, __err); + 7, __io, __tmperr); break; case 'h': case 'b': @@ -1924,77 +1925,77 @@ _GLIBCXX_END_LDBL_NAMESPACE const char_type* __months1[12]; __tp._M_months_abbreviated(__months1); __beg = _M_extract_name(__beg, __end, __tm->tm_mon, - __months1, 12, __io, __err); + __months1, 12, __io, __tmperr); break; case 'B': // Month name [tm_mon]. const char_type* __months2[12]; __tp._M_months(__months2); __beg = _M_extract_name(__beg, __end, __tm->tm_mon, - __months2, 12, __io, __err); + __months2, 12, __io, __tmperr); break; case 'c': // Default time and date representation. const char_type* __dt[2]; __tp._M_date_time_formats(__dt); - __beg = _M_extract_via_format(__beg, __end, __io, __err, + __beg = _M_extract_via_format(__beg, __end, __io, __tmperr, __tm, __dt[0]); break; case 'd': // Day [01, 31]. [tm_mday] __beg = _M_extract_num(__beg, __end, __tm->tm_mday, 1, 31, 2, - __io, __err); + __io, __tmperr); break; case 'e': // Day [1, 31], with single digits preceded by // space. [tm_mday] if (__ctype.is(ctype_base::space, *__beg)) __beg = _M_extract_num(++__beg, __end, __tm->tm_mday, 1, 9, - 1, __io, __err); + 1, __io, __tmperr); else __beg = _M_extract_num(__beg, __end, __tm->tm_mday, 10, 31, - 2, __io, __err); + 2, __io, __tmperr); break; case 'D': // Equivalent to %m/%d/%y.[tm_mon, tm_mday, tm_year] __cs = "%m/%d/%y"; __ctype.widen(__cs, __cs + 9, __wcs); - __beg = _M_extract_via_format(__beg, __end, __io, __err, + __beg = _M_extract_via_format(__beg, __end, __io, __tmperr, __tm, __wcs); break; case 'H': // Hour [00, 23]. [tm_hour] __beg = _M_extract_num(__beg, __end, __tm->tm_hour, 0, 23, 2, - __io, __err); + __io, __tmperr); break; case 'I': // Hour [01, 12]. [tm_hour] __beg = _M_extract_num(__beg, __end, __tm->tm_hour, 1, 12, 2, - __io, __err); + __io, __tmperr); break; case 'm': // Month [01, 12]. [tm_mon] __beg = _M_extract_num(__beg, __end, __mem, 1, 12, 2, - __io, __err); - if (!__err) + __io, __tmperr); + if (!__tmperr) __tm->tm_mon = __mem - 1; break; case 'M': // Minute [00, 59]. [tm_min] __beg = _M_extract_num(__beg, __end, __tm->tm_min, 0, 59, 2, - __io, __err); + __io, __tmperr); break; case 'n': if (__ctype.narrow(*__beg, 0) == '\n') ++__beg; else - __err |= ios_base::failbit; + __tmperr |= ios_base::failbit; break; case 'R': // Equivalent to (%H:%M). __cs = "%H:%M"; __ctype.widen(__cs, __cs + 6, __wcs); - __beg = _M_extract_via_format(__beg, __end, __io, __err, + __beg = _M_extract_via_format(__beg, __end, __io, __tmperr, __tm, __wcs); break; case 'S': @@ -2005,46 +2006,46 @@ _GLIBCXX_END_LDBL_NAMESPACE #else __beg = _M_extract_num(__beg, __end, __tm->tm_sec, 0, 61, 2, #endif - __io, __err); + __io, __tmperr); break; case 't': if (__ctype.narrow(*__beg, 0) == '\t') ++__beg; else - __err |= ios_base::failbit; + __tmperr |= ios_base::failbit; break; case 'T': // Equivalent to (%H:%M:%S). __cs = "%H:%M:%S"; __ctype.widen(__cs, __cs + 9, __wcs); - __beg = _M_extract_via_format(__beg, __end, __io, __err, + __beg = _M_extract_via_format(__beg, __end, __io, __tmperr, __tm, __wcs); break; case 'x': // Locale's date. const char_type* __dates[2]; __tp._M_date_formats(__dates); - __beg = _M_extract_via_format(__beg, __end, __io, __err, + __beg = _M_extract_via_format(__beg, __end, __io, __tmperr, __tm, __dates[0]); break; case 'X': // Locale's time. const char_type* __times[2]; __tp._M_time_formats(__times); - __beg = _M_extract_via_format(__beg, __end, __io, __err, + __beg = _M_extract_via_format(__beg, __end, __io, __tmperr, __tm, __times[0]); break; case 'y': case 'C': // C99 // Two digit year. [tm_year] __beg = _M_extract_num(__beg, __end, __tm->tm_year, 0, 99, 2, - __io, __err); + __io, __tmperr); break; case 'Y': // Year [1900). [tm_year] __beg = _M_extract_num(__beg, __end, __mem, 0, 9999, 4, - __io, __err); - if (!__err) + __io, __tmperr); + if (!__tmperr) __tm->tm_year = __mem - 1900; break; case 'Z': @@ -2054,25 +2055,25 @@ _GLIBCXX_END_LDBL_NAMESPACE int __tmp; __beg = _M_extract_name(__beg, __end, __tmp, __timepunct_cache<_CharT>::_S_timezones, - 14, __io, __err); + 14, __io, __tmperr); // GMT requires special effort. - if (__beg != __end && !__err && __tmp == 0 + if (__beg != __end && !__tmperr && __tmp == 0 && (*__beg == __ctype.widen('-') || *__beg == __ctype.widen('+'))) { __beg = _M_extract_num(__beg, __end, __tmp, 0, 23, 2, - __io, __err); + __io, __tmperr); __beg = _M_extract_num(__beg, __end, __tmp, 0, 59, 2, - __io, __err); + __io, __tmperr); } } else - __err |= ios_base::failbit; + __tmperr |= ios_base::failbit; break; default: // Not recognized. - __err |= ios_base::failbit; + __tmperr |= ios_base::failbit; } } else @@ -2081,9 +2082,13 @@ _GLIBCXX_END_LDBL_NAMESPACE if (__format[__i] == *__beg) ++__beg; else - __err |= ios_base::failbit; + __tmperr |= ios_base::failbit; } } + + if (__tmperr) + __err |= ios_base::failbit; + return __beg; } @@ -2121,6 +2126,7 @@ _GLIBCXX_END_LDBL_NAMESPACE __member = __value; else __err |= ios_base::failbit; + return __beg; } @@ -2196,6 +2202,7 @@ _GLIBCXX_END_LDBL_NAMESPACE __testvalid = false; if (!__testvalid) __err |= ios_base::failbit; + return __beg; } @@ -2246,7 +2253,9 @@ _GLIBCXX_END_LDBL_NAMESPACE const char_type* __days[7]; __tp._M_days_abbreviated(__days); int __tmpwday; - __beg = _M_extract_name(__beg, __end, __tmpwday, __days, 7, __io, __err); + ios_base::iostate __tmperr = ios_base::goodbit; + __beg = _M_extract_name(__beg, __end, __tmpwday, __days, 7, + __io, __tmperr); // Check to see if non-abbreviated name exists, and extract. // NB: Assumes both _M_days and _M_days_abbreviated organized in @@ -2254,7 +2263,7 @@ _GLIBCXX_END_LDBL_NAMESPACE // __days array with the same index points to a day, and that // day's abbreviated form. // NB: Also assumes that an abbreviated name is a subset of the name. - if (!__err && __beg != __end) + if (!__tmperr && __beg != __end) { size_t __pos = __traits_type::length(__days[__tmpwday]); __tp._M_days(__days); @@ -2267,12 +2276,14 @@ _GLIBCXX_END_LDBL_NAMESPACE && __name[__pos] == *__beg) ++__beg, ++__pos; if (__len != __pos) - __err |= ios_base::failbit; + __tmperr |= ios_base::failbit; } } - if (!__err) + if (!__tmperr) __tm->tm_wday = __tmpwday; - + else + __err |= ios_base::failbit; + if (__beg == __end) __err |= ios_base::eofbit; return __beg; @@ -2291,8 +2302,9 @@ _GLIBCXX_END_LDBL_NAMESPACE const char_type* __months[12]; __tp._M_months_abbreviated(__months); int __tmpmon; + ios_base::iostate __tmperr = ios_base::goodbit; __beg = _M_extract_name(__beg, __end, __tmpmon, __months, 12, - __io, __err); + __io, __tmperr); // Check to see if non-abbreviated name exists, and extract. // NB: Assumes both _M_months and _M_months_abbreviated organized in @@ -2300,7 +2312,7 @@ _GLIBCXX_END_LDBL_NAMESPACE // __months array with the same index points to a month, and that // month's abbreviated form. // NB: Also assumes that an abbreviated name is a subset of the name. - if (!__err && __beg != __end) + if (!__tmperr && __beg != __end) { size_t __pos = __traits_type::length(__months[__tmpmon]); __tp._M_months(__months); @@ -2313,11 +2325,13 @@ _GLIBCXX_END_LDBL_NAMESPACE && __name[__pos] == *__beg) ++__beg, ++__pos; if (__len != __pos) - __err |= ios_base::failbit; + __tmperr |= ios_base::failbit; } } - if (!__err) + if (!__tmperr) __tm->tm_mon = __tmpmon; + else + __err |= ios_base::failbit; if (__beg == __end) __err |= ios_base::eofbit; @@ -2347,6 +2361,7 @@ _GLIBCXX_END_LDBL_NAMESPACE __tm->tm_year = __i == 2 ? __value : __value - 1900; else __err |= ios_base::failbit; + if (__beg == __end) __err |= ios_base::eofbit; return __beg; 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 0000000..e20b006 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_date/char/5.cc @@ -0,0 +1,71 @@ +// 2006-06-16 Paolo Carlini + +// Copyright (C) 2006 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 22.2.5.1.1 time_get members + +#include +#include +#include + +// 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 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(iss.getloc()); + + const string str0 = "1"; + iter_type end0 = 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/wchar_t/5.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_date/wchar_t/5.cc new file mode 100644 index 0000000..4ad37d9 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_date/wchar_t/5.cc @@ -0,0 +1,71 @@ +// 2006-06-16 Paolo Carlini + +// Copyright (C) 2006 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 22.2.5.1.1 time_get members + +#include +#include +#include + +// 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 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(iss.getloc()); + + const wstring str0 = L"1"; + iter_type end0 = 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_monthname/char/5.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/char/5.cc new file mode 100644 index 0000000..bd6bfb5 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/char/5.cc @@ -0,0 +1,67 @@ +// 2006-06-16 Paolo Carlini + +// Copyright (C) 2006 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 22.2.5.1.1 time_get members + +#include +#include +#include + +// 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 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(iss.getloc()); + + const string str0 = "S"; + iter_type end0 = 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/wchar_t/5.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/wchar_t/5.cc new file mode 100644 index 0000000..e209a0a0 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/wchar_t/5.cc @@ -0,0 +1,67 @@ +// 2006-06-16 Paolo Carlini + +// Copyright (C) 2006 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 22.2.5.1.1 time_get members + +#include +#include +#include + +// 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 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(iss.getloc()); + + const wstring str0 = L"S"; + iter_type end0 = 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_time/char/5.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_time/char/5.cc new file mode 100644 index 0000000..d4b5baf --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_time/char/5.cc @@ -0,0 +1,72 @@ +// 2006-06-16 Paolo Carlini + +// Copyright (C) 2006 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 22.2.5.1.1 time_get members + +#include +#include +#include + +// 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 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(iss.getloc()); + + const string str0 = "1"; + iter_type end0 = 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/wchar_t/5.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_time/wchar_t/5.cc new file mode 100644 index 0000000..fb6b36f --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_time/wchar_t/5.cc @@ -0,0 +1,72 @@ +// 2006-06-16 Paolo Carlini + +// Copyright (C) 2006 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 22.2.5.1.1 time_get members + +#include +#include +#include + +// 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 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(iss.getloc()); + + const wstring str0 = L"1"; + iter_type end0 = 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_weekday/char/5.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/char/5.cc new file mode 100644 index 0000000..457cb3c --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/char/5.cc @@ -0,0 +1,68 @@ +// 2006-06-16 Paolo Carlini + +// Copyright (C) 2006 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 22.2.5.1.1 time_get members + +#include +#include +#include + +// 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 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(iss.getloc()); + + const string str0 = "T"; + iter_type end0 = 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/wchar_t/5.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/wchar_t/5.cc new file mode 100644 index 0000000..402c949 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_weekday/wchar_t/5.cc @@ -0,0 +1,68 @@ +// 2006-06-16 Paolo Carlini + +// Copyright (C) 2006 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 22.2.5.1.1 time_get members + +#include +#include +#include + +// 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 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(iss.getloc()); + + const wstring str0 = L"T"; + iter_type end0 = 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_year/char/5.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_year/char/5.cc new file mode 100644 index 0000000..3182719 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_year/char/5.cc @@ -0,0 +1,68 @@ +// 2006-06-16 Paolo Carlini + +// Copyright (C) 2006 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 22.2.5.1.1 time_get members + +#include +#include +#include + +// 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 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(iss.getloc()); + + const string str0 = "1"; + iter_type end0 = 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/wchar_t/5.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_year/wchar_t/5.cc new file mode 100644 index 0000000..9fc1435 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_year/wchar_t/5.cc @@ -0,0 +1,68 @@ +// 2006-06-16 Paolo Carlini + +// Copyright (C) 2006 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 22.2.5.1.1 time_get members + +#include +#include +#include + +// 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 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(iss.getloc()); + + const wstring str0 = L"1"; + iter_type end0 = 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; +} -- 2.7.4