OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libstdc++-v3/] [testsuite/] [22_locale/] [time_get/] [get_monthname/] [wchar_t/] [1.cc] - Blame information for rev 19

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 jlechner
// 2001-09-21 Benjamin Kosnik  <bkoz@redhat.com>
2
 
3
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation
4
//
5
// This file is part of the GNU ISO C++ Library.  This library is free
6
// software; you can redistribute it and/or modify it under the
7
// terms of the GNU General Public License as published by the
8
// Free Software Foundation; either version 2, or (at your option)
9
// any later version.
10
 
11
// This library is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
// GNU General Public License for more details.
15
 
16
// You should have received a copy of the GNU General Public License along
17
// with this library; see the file COPYING.  If not, write to the Free
18
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19
// USA.
20
 
21
// 22.2.5.1.1 time_get members
22
 
23
#include <locale>
24
#include <sstream>
25
#include <testsuite_hooks.h>
26
 
27
void test01()
28
{
29
  using namespace std;
30
  bool test __attribute__((unused)) = true;
31
 
32
  typedef istreambuf_iterator<wchar_t> iterator_type;
33
 
34
  const ios_base::iostate good = ios_base::goodbit;
35
  ios_base::iostate errorstate = good;
36
 
37
  // basic construction
38
  locale loc_c = locale::classic();
39
 
40
  // create "C" time objects
41
  const tm time_bday = __gnu_test::test_tm(0, 0, 12, 4, 3, 71, 0, 93, 0);
42
 
43
  // iter_type 
44
  // get_monthname(iter_type, iter_type, ios_base&, 
45
  //               ios_base::iostate&, tm*) const
46
 
47
  // sanity checks for "C" locale
48
  iterator_type end;
49
  wistringstream iss;
50
  iss.imbue(loc_c);
51
  const time_get<wchar_t>& tim_get = use_facet<time_get<wchar_t> >(iss.getloc());
52
 
53
  iss.str(L"April");
54
  iterator_type is_it01(iss);
55
  tm time01;
56
  errorstate = good;
57
  tim_get.get_monthname(is_it01, end, iss, errorstate, &time01);
58
  VERIFY( time01.tm_mon == time_bday.tm_mon );
59
  VERIFY( errorstate == ios_base::eofbit );
60
 
61
  iss.str(L"Apr");
62
  iterator_type is_it02(iss);
63
  tm time02;
64
  errorstate = good;
65
  tim_get.get_monthname(is_it02, end, iss, errorstate, &time02);
66
  VERIFY( time02.tm_mon == time_bday.tm_mon );
67
  VERIFY( errorstate == ios_base::eofbit );
68
 
69
  iss.str(L"Apr ");
70
  iterator_type is_it03(iss);
71
  tm time03;
72
  errorstate = good;
73
  iterator_type ret03 = tim_get.get_monthname(is_it03, end, iss, errorstate,
74
                                              &time03);
75
  VERIFY( time03.tm_mon == time_bday.tm_mon );
76
  VERIFY( errorstate == good );
77
  VERIFY( *ret03 == L' ' );
78
 
79
  iss.str(L"Aar");
80
  iterator_type is_it04(iss);
81
  tm time04;
82
  time04.tm_mon = 5;
83
  errorstate = good;
84
  iterator_type ret04 = tim_get.get_monthname(is_it04, end, iss, errorstate,
85
                                              &time04);
86
  VERIFY( time04.tm_mon == 5 );
87
  VERIFY( *ret04 == L'a' );
88
  VERIFY( errorstate == ios_base::failbit );
89
 
90
  iss.str(L"December ");
91
  iterator_type is_it05(iss);
92
  tm time05;
93
  errorstate = good;
94
  iterator_type ret05 = tim_get.get_monthname(is_it05, end, iss, errorstate,
95
                                              &time05);
96
  VERIFY( time05.tm_mon == 11 );
97
  VERIFY( errorstate == good );
98
  VERIFY( *ret05 == L' ' );
99
 
100
  iss.str(L"Decelember ");
101
  iterator_type is_it06(iss);
102
  tm time06;
103
  time06.tm_mon = 4;
104
  errorstate = good;
105
  iterator_type ret06 = tim_get.get_monthname(is_it06, end, iss, errorstate,
106
                                              &time06);
107
  VERIFY( time06.tm_mon == 4 );
108
  VERIFY( errorstate == ios_base::failbit );
109
  VERIFY( *ret06 == L'l' );
110
}
111
 
112
int main()
113
{
114
  test01();
115
  return 0;
116
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.