1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // REQUIRES: locale.en_US.UTF-8
11 // REQUIRES: locale.fr_FR.UTF-8
12 // REQUIRES: locale.ru_RU.UTF-8
13 // REQUIRES: locale.zh_CN.UTF-8
17 // class time_get_byname<charT, InputIterator>
19 // iter_type get_year(iter_type s, iter_type end, ios_base& str,
20 // ios_base::iostate& err, tm* t) const;
24 #include "test_iterators.h"
26 #include "platform_support.h" // locale name macros
28 typedef input_iterator<const wchar_t*> I;
30 typedef std::time_get_byname<wchar_t, I> F;
36 explicit my_facet(const std::string& nm, std::size_t refs = 0)
43 std::ios_base::iostate err;
46 const my_facet f(LOCALE_en_US_UTF_8, 1);
47 const wchar_t in[] = L"2009";
48 err = std::ios_base::goodbit;
50 I i = f.get_year(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
51 assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
52 assert(t.tm_year == 109);
53 assert(err == std::ios_base::eofbit);
56 const my_facet f(LOCALE_fr_FR_UTF_8, 1);
57 const wchar_t in[] = L"2009";
58 err = std::ios_base::goodbit;
60 I i = f.get_year(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
61 assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
62 assert(t.tm_year == 109);
63 assert(err == std::ios_base::eofbit);
66 const my_facet f(LOCALE_ru_RU_UTF_8, 1);
67 const wchar_t in[] = L"2009";
68 err = std::ios_base::goodbit;
70 I i = f.get_year(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
71 assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
72 assert(t.tm_year == 109);
73 assert(err == std::ios_base::eofbit);
76 const my_facet f(LOCALE_zh_CN_UTF_8, 1);
77 const wchar_t in[] = L"2009";
78 err = std::ios_base::goodbit;
80 I i = f.get_year(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
81 assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
82 assert(t.tm_year == 109);
83 assert(err == std::ios_base::eofbit);