| 1 | // { dg-do run { target c++11 } } |
| 2 | |
| 3 | #include <locale> |
| 4 | #include <sstream> |
| 5 | #include <testsuite_hooks.h> |
| 6 | |
| 7 | int main() |
| 8 | { |
| 9 | using Facet = std::time_get<char>; |
| 10 | const Facet& fac = std::use_facet<Facet>(std::locale::classic()); |
| 11 | std::istringstream ss("Fri Jul 5 14:58:21 2019"); |
| 12 | std::ios::iostate err = std::ios::goodbit; |
| 13 | std::tm tm = {}; |
| 14 | fac.get(ss, Facet::iter_type(), ss, err, &tm, 'c'); |
| 15 | VERIFY( err == std::ios::eofbit ); |
| 16 | VERIFY( tm.tm_year == 119 ); |
| 17 | VERIFY( tm.tm_mon == 6 ); |
| 18 | VERIFY( tm.tm_mday == 5 ); |
| 19 | VERIFY( tm.tm_wday == 5 ); |
| 20 | VERIFY( tm.tm_hour == 14 ); |
| 21 | VERIFY( tm.tm_min == 58 ); |
| 22 | VERIFY( tm.tm_sec == 21 ); |
| 23 | ss.clear(); |
| 24 | ss.seekg(0); |
| 25 | ss.str(ss.str() + " non-whitespace after the datetime"); |
| 26 | err = std::ios::goodbit; |
| 27 | tm = std::tm(); |
| 28 | fac.get(ss, Facet::iter_type(), ss, err, &tm, 'c', 'E'); |
| 29 | VERIFY( err == std::ios::goodbit ); |
| 30 | VERIFY( tm.tm_year == 119 ); |
| 31 | VERIFY( tm.tm_mon == 6 ); |
| 32 | VERIFY( tm.tm_mday == 5 ); |
| 33 | VERIFY( tm.tm_wday == 5 ); |
| 34 | VERIFY( tm.tm_hour == 14 ); |
| 35 | VERIFY( tm.tm_min == 58 ); |
| 36 | VERIFY( tm.tm_sec == 21 ); |
| 37 | } |