get_weekday_wide.pass.cpp revision 239e341c94184e2ed2357f2e054c84fbb1fbed2a
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// <locale> 11 12// class time_get_byname<charT, InputIterator> 13 14// iter_type 15// get_weekday(iter_type s, iter_type end, ios_base& str, 16// ios_base::iostate& err, tm* t) const; 17 18#include <locale> 19#include <cassert> 20#include "../../../../iterators.h" 21 22#include "../../../../platform_support.h" // locale name macros 23 24typedef input_iterator<const wchar_t*> I; 25 26typedef std::time_get_byname<wchar_t, I> F; 27 28class my_facet 29 : public F 30{ 31public: 32 explicit my_facet(const std::string& nm, std::size_t refs = 0) 33 : F(nm, refs) {} 34}; 35 36int main() 37{ 38 std::ios ios(0); 39 std::ios_base::iostate err; 40 std::tm t; 41 { 42 const my_facet f(LOCALE_en_US_UTF_8, 1); 43 const wchar_t in[] = L"Monday"; 44 err = std::ios_base::goodbit; 45 t = std::tm(); 46 I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t); 47 assert(i.base() == in+sizeof(in)/sizeof(in[0])-1); 48 assert(t.tm_wday == 1); 49 assert(err == std::ios_base::eofbit); 50 } 51 { 52 const my_facet f(LOCALE_fr_FR_UTF_8, 1); 53 const wchar_t in[] = L"Lundi"; 54 err = std::ios_base::goodbit; 55 t = std::tm(); 56 I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t); 57 assert(i.base() == in+sizeof(in)/sizeof(in[0])-1); 58 assert(t.tm_wday == 1); 59 assert(err == std::ios_base::eofbit); 60 } 61 { 62 const my_facet f(LOCALE_ru_RU_UTF_8, 1); 63 const wchar_t in[] = L"\x43F\x43E\x43D\x435\x434\x435\x43B\x44C\x43D\x438\x43A"; 64 err = std::ios_base::goodbit; 65 t = std::tm(); 66 I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t); 67 assert(i.base() == in+sizeof(in)/sizeof(in[0])-1); 68 assert(t.tm_wday == 1); 69 assert(err == std::ios_base::eofbit); 70 } 71 { 72 const my_facet f(LOCALE_zh_CN_UTF_8, 1); 73 const wchar_t in[] = L"\x661F\x671F\x4E00"; 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