1// { dg-require-namedlocale "" }
2
3// 2004-08-25  Paolo Carlini  <pcarlini@suse.de>
4
5// Copyright (C) 2004, 2005, 2006 Free Software Foundation
6//
7// This file is part of the GNU ISO C++ Library.  This library is free
8// software; you can redistribute it and/or modify it under the
9// terms of the GNU General Public License as published by the
10// Free Software Foundation; either version 2, or (at your option)
11// any later version.
12
13// This library is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16// GNU General Public License for more details.
17
18// You should have received a copy of the GNU General Public License along
19// with this library; see the file COPYING.  If not, write to the Free
20// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21// USA.
22
23// 22.2.5.3.1 time_put members
24
25#include <locale>
26#include <sstream>
27#include <testsuite_hooks.h>
28
29// libstdc++/17038
30void test01()
31{
32  using namespace std;
33  typedef ostreambuf_iterator<char> iterator_type;
34
35  bool test __attribute__((unused)) = true;
36
37  // create "C" time objects
38  const tm time1 = __gnu_test::test_tm(0, 0, 12, 4, 3, 71, 0, 93, 0);
39
40  // basic construction
41  locale loc_c = locale::classic();
42  locale loc_in = locale("ta_IN");
43  VERIFY( loc_in != loc_c );
44
45  // create an ostream-derived object, cache the time_put facet
46  ostringstream oss;
47  oss.imbue(loc_in);
48  const time_put<char>& tim_put =
49    use_facet<time_put<char> >(oss.getloc());
50
51  iterator_type os_it01 = tim_put.put(oss.rdbuf(), oss, '*', &time1, 'c');
52  string result1 = oss.str();
53
54  char time_buffer[128];
55  setlocale(LC_ALL, "ta_IN");
56  VERIFY( strftime(time_buffer, 128, "%c", &time1) );
57
58  VERIFY( result1 == time_buffer );
59}
60
61int main()
62{
63  test01();
64  return 0;
65}
66