150276Speter// { dg-require-namedlocale "en_HK" }
250276Speter// { dg-require-namedlocale "de_DE" }
3184989Srafan
450276Speter// 2001-09-21 Benjamin Kosnik  <bkoz@redhat.com>
550276Speter
650276Speter// Copyright (C) 2001-2015 Free Software Foundation, Inc.
750276Speter//
850276Speter// This file is part of the GNU ISO C++ Library.  This library is free
950276Speter// software; you can redistribute it and/or modify it under the
1050276Speter// terms of the GNU General Public License as published by the
1150276Speter// Free Software Foundation; either version 3, or (at your option)
1250276Speter// any later version.
1350276Speter
1450276Speter// This library is distributed in the hope that it will be useful,
1550276Speter// but WITHOUT ANY WARRANTY; without even the implied warranty of
1650276Speter// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1750276Speter// GNU General Public License for more details.
1850276Speter
1950276Speter// You should have received a copy of the GNU General Public License along
2050276Speter// with this library; see the file COPYING3.  If not see
2150276Speter// <http://www.gnu.org/licenses/>.
2250276Speter
2350276Speter// 22.2.5.1.1 time_get members
2450276Speter
2550276Speter#include <locale>
2650276Speter#include <sstream>
2750276Speter#include <testsuite_hooks.h>
2850276Speter
2950276Spetervoid test02()
30184989Srafan{
3150276Speter  using namespace std;
3250276Speter  bool test __attribute__((unused)) = true;
3350276Speter
3450276Speter  typedef istreambuf_iterator<char> iterator_type;
3550276Speter
3650276Speter  // basic construction and sanity checks.
3750276Speter  locale loc_c = locale::classic();
3850276Speter  locale loc_hk = locale("en_HK");
3950276Speter  locale loc_de = locale("de_DE");
4050276Speter  VERIFY( loc_hk != loc_c );
4150276Speter  VERIFY( loc_hk != loc_de );
4250276Speter
4350276Speter  const tm time_bday = __gnu_test::test_tm(0, 0, 12, 4, 3, 71, 0, 93, 0);
4450276Speter
4550276Speter  const string empty;
4650276Speter
4750276Speter  const ios_base::iostate good = ios_base::goodbit;
4850276Speter  ios_base::iostate errorstate = good;
49184989Srafan
50184989Srafan  // create an ostream-derived object, cache the time_get facet
51184989Srafan  iterator_type end;
52184989Srafan
53184989Srafan  istringstream iss;
54184989Srafan  iss.imbue(loc_de);
55184989Srafan  const time_get<char>& tim_get = use_facet<time_get<char> >(iss.getloc());
56184989Srafan
57184989Srafan  // inspection of named locales, de_DE
58184989Srafan  iss.str("April");
59184989Srafan  iterator_type is_it10(iss);
60184989Srafan  tm time10;
61184989Srafan  errorstate = good;
62184989Srafan  tim_get.get_monthname(is_it10, end, iss, errorstate, &time10);
63184989Srafan  VERIFY( time10.tm_mon == time_bday.tm_mon );
64184989Srafan  VERIFY( errorstate == ios_base::eofbit );
65184989Srafan
66184989Srafan  // inspection of named locales, en_HK
67184989Srafan  iss.imbue(loc_hk);
68184989Srafan  const time_get<char>& tim_get2 = use_facet<time_get<char> >(iss.getloc());
69184989Srafan  iss.str("April");
70184989Srafan  iterator_type is_it20(iss);
71184989Srafan  tm time20;
72184989Srafan  errorstate = good;
73184989Srafan  tim_get2.get_monthname(is_it20, end, iss, errorstate, &time20);
74184989Srafan  VERIFY( time20.tm_mon == time_bday.tm_mon );
75184989Srafan  VERIFY( errorstate == ios_base::eofbit );
76184989Srafan}
77184989Srafan
78184989Srafanint main()
79184989Srafan{
80184989Srafan  test02();
81184989Srafan  return 0;
8250276Speter}
83184989Srafan