1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 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 14 15 // <locale> 16 17 // class time_get_byname<charT, InputIterator> 18 19 // iter_type 20 // get_weekday(iter_type s, iter_type end, ios_base& str, 21 // ios_base::iostate& err, tm* t) const; 22 23 // TODO: investigation needed 24 // XFAIL: linux-gnu 25 26 #include <locale> 27 #include <cassert> 28 #include "test_iterators.h" 29 30 #include "platform_support.h" // locale name macros 31 32 typedef input_iterator<const char*> I; 33 34 typedef std::time_get_byname<char, I> F; 35 36 class my_facet 37 : public F 38 { 39 public: 40 explicit my_facet(const std::string& nm, std::size_t refs = 0) 41 : F(nm, refs) {} 42 }; 43 44 int main() 45 { 46 std::ios ios(0); 47 std::ios_base::iostate err; 48 std::tm t; 49 { 50 const my_facet f(LOCALE_en_US_UTF_8, 1); 51 const char in[] = "Monday"; 52 err = std::ios_base::goodbit; 53 t = std::tm(); 54 I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t); 55 assert(i.base() == in+sizeof(in)/sizeof(in[0])-1); 56 assert(t.tm_wday == 1); 57 assert(err == std::ios_base::eofbit); 58 } 59 { 60 const my_facet f(LOCALE_fr_FR_UTF_8, 1); 61 const char in[] = "Lundi"; 62 err = std::ios_base::goodbit; 63 t = std::tm(); 64 I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t); 65 assert(i.base() == in+sizeof(in)/sizeof(in[0])-1); 66 assert(t.tm_wday == 1); 67 assert(err == std::ios_base::eofbit); 68 } 69 { 70 const my_facet f(LOCALE_ru_RU_UTF_8, 1); 71 const char in[] = "\xD0\xBF\xD0\xBE\xD0\xBD\xD0\xB5" 72 "\xD0\xB4\xD0\xB5\xD0\xBB\xD1\x8C" 73 "\xD0\xBD\xD0\xB8\xD0\xBA"; 74 err = std::ios_base::goodbit; 75 t = std::tm(); 76 I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t); 77 assert(i.base() == in+sizeof(in)/sizeof(in[0])-1); 78 assert(t.tm_wday == 1); 79 assert(err == std::ios_base::eofbit); 80 } 81 { 82 const my_facet f(LOCALE_zh_CN_UTF_8, 1); 83 const char in[] = "\xE6\x98\x9F\xE6\x9C\x9F\xE4\xB8\x80"; 84 err = std::ios_base::goodbit; 85 t = std::tm(); 86 I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t); 87 assert(i.base() == in+sizeof(in)/sizeof(in[0])-1); 88 assert(t.tm_wday == 1); 89 assert(err == std::ios_base::eofbit); 90 } 91 } 92