Merge from mainline
[official-gcc.git] / libstdc++-v3 / testsuite / 22_locale / time_put / put / char / 17038.cc
blobaa456fc44582d41afd97b99ca886f4529f52e4aa
1 // { dg-require-namedlocale "" }
3 // 2004-08-25 Paolo Carlini <pcarlini@suse.de>
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.
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.
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.
23 // 22.2.5.3.1 time_put members
25 #include <locale>
26 #include <sstream>
27 #include <testsuite_hooks.h>
29 // libstdc++/17038
30 void test01()
32 using namespace std;
33 typedef ostreambuf_iterator<char> iterator_type;
35 bool test __attribute__((unused)) = true;
37 // create "C" time objects
38 const tm time1 = __gnu_test::test_tm(0, 0, 12, 4, 3, 71, 0, 93, 0);
40 // basic construction
41 locale loc_c = locale::classic();
42 locale loc_in = locale("ta_IN");
43 VERIFY( loc_in != loc_c );
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());
51 iterator_type os_it01 = tim_put.put(oss.rdbuf(), oss, '*', &time1, 'c');
52 string result1 = oss.str();
54 char time_buffer[128];
55 setlocale(LC_ALL, "ta_IN");
56 VERIFY( strftime(time_buffer, 128, "%c", &time1) );
58 VERIFY( result1 == time_buffer );
61 int main()
63 test01();
64 return 0;