Merge -r 127928:132243 from trunk
[official-gcc.git] / libstdc++-v3 / testsuite / 22_locale / time_put / put / char / 5.cc
blobcf38a79902ec7c21d20232cd97a8e377ca3bc997
1 // 2001-09-17 Benjamin Kosnik <bkoz@redhat.com>
3 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
4 // Free Software Foundation
5 //
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 2, or (at your option)
10 // any later version.
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING. If not, write to the Free
19 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20 // USA.
22 // 22.2.5.3.1 time_put members
24 #include <locale>
25 #include <sstream>
26 #include <testsuite_hooks.h>
28 void test05()
30 using namespace std;
31 typedef ostreambuf_iterator<char> iterator_type;
32 typedef char_traits<char> traits;
34 bool test __attribute__((unused)) = true;
36 // create "C" time objects
37 const tm time1 = __gnu_test::test_tm(0, 0, 12, 4, 3, 71, 0, 93, 0);
38 const char* date = "%A, the second of %B";
39 const char* date_ex = "%Ex";
41 // basic construction
42 locale loc_c = locale::classic();
44 // create an ostream-derived object, cache the time_put facet
45 const string empty;
46 ostringstream oss;
47 oss.imbue(loc_c);
48 const time_put<char>& tim_put = use_facet<time_put<char> >(oss.getloc());
50 // 2
51 oss.str(empty);
52 iterator_type os_it05 = tim_put.put(oss.rdbuf(), oss, '*', &time1,
53 date, date + traits::length(date));
54 string result5 = oss.str();
55 VERIFY( result5 == "Sunday, the second of April");
56 iterator_type os_it06 = tim_put.put(oss.rdbuf(), oss, '*', &time1,
57 date_ex,
58 date_ex + traits::length(date_ex));
59 string result6 = oss.str();
60 VERIFY( result6 != result5 );
63 int main()
65 test05();
66 return 0;