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>
20 // get_weekday(iter_type s, iter_type end, ios_base& str,
21 // ios_base::iostate& err, tm* t) const;
25 #include "test_iterators.h"
27 #include "platform_support.h" // locale name macros
29 typedef input_iterator<const char*> I;
31 typedef std::time_get_byname<char, I> F;
37 explicit my_facet(const std::string& nm, std::size_t refs = 0)
44 std::ios_base::iostate err;
47 const my_facet f(LOCALE_en_US_UTF_8, 1);
48 const char in[] = "Monday";
49 err = std::ios_base::goodbit;
51 I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
52 assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
53 assert(t.tm_wday == 1);
54 assert(err == std::ios_base::eofbit);
57 const my_facet f(LOCALE_fr_FR_UTF_8, 1);
58 const char in[] = "Lundi";
59 err = std::ios_base::goodbit;
61 I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
62 assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
63 assert(t.tm_wday == 1);
64 assert(err == std::ios_base::eofbit);
67 const my_facet f(LOCALE_ru_RU_UTF_8, 1);
68 const char in[] = "\xD0\xBF\xD0\xBE\xD0\xBD\xD0\xB5"
69 "\xD0\xB4\xD0\xB5\xD0\xBB\xD1\x8C"
70 "\xD0\xBD\xD0\xB8\xD0\xBA";
71 err = std::ios_base::goodbit;
73 I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
74 assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
75 assert(t.tm_wday == 1);
76 assert(err == std::ios_base::eofbit);
79 const my_facet f(LOCALE_zh_CN_UTF_8, 1);
80 const char in[] = "\xE6\x98\x9F\xE6\x9C\x9F\xE4\xB8\x80";
81 err = std::ios_base::goodbit;
83 I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
84 assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
85 assert(t.tm_wday == 1);
86 assert(err == std::ios_base::eofbit);