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
15 // GLIBC Expects "10/06/2009" for fr_FR as opposed to "10.06.2009"
16 // GLIBC also failes on the zh_CN test.
21 // class time_get_byname<charT, InputIterator>
24 // get_date(iter_type s, iter_type end, ios_base& str,
25 // ios_base::iostate& err, tm* t) const;
29 #include "test_iterators.h"
31 #include "platform_support.h" // locale name macros
33 typedef input_iterator<const char*> I;
35 typedef std::time_get_byname<char, I> F;
41 explicit my_facet(const std::string& nm, std::size_t refs = 0)
48 std::ios_base::iostate err;
51 const my_facet f(LOCALE_en_US_UTF_8, 1);
52 const char in[] = "06/10/2009";
53 err = std::ios_base::goodbit;
55 I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
56 assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
57 assert(t.tm_mon == 5);
58 assert(t.tm_mday == 10);
59 assert(t.tm_year == 109);
60 assert(err == std::ios_base::eofbit);
63 const my_facet f(LOCALE_fr_FR_UTF_8, 1);
64 const char in[] = "10.06.2009";
65 err = std::ios_base::goodbit;
67 I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
68 assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
69 assert(t.tm_mon == 5);
70 assert(t.tm_mday == 10);
71 assert(t.tm_year == 109);
72 assert(err == std::ios_base::eofbit);
75 const my_facet f(LOCALE_ru_RU_UTF_8, 1);
76 const char in[] = "10.06.2009";
77 err = std::ios_base::goodbit;
79 I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
80 assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
81 assert(t.tm_mon == 5);
82 assert(t.tm_mday == 10);
83 assert(t.tm_year == 109);
84 assert(err == std::ios_base::eofbit);
88 const my_facet f(LOCALE_zh_CN_UTF_8, 1);
89 const char in[] = "2009/06/10";
90 err = std::ios_base::goodbit;
92 I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
93 assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
94 assert(t.tm_mon == 5);
95 assert(t.tm_mday == 10);
96 assert(t.tm_year == 109);
97 assert(err == std::ios_base::eofbit);