get_weekday_wide.pass.cpp revision b64f8b07c104c6cc986570ac8ee0ed16a9f23976
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 22typedef input_iterator<const wchar_t*> I; 23 24typedef std::time_get_byname<wchar_t, I> F; 25 26class my_facet 27 : public F 28{ 29public: 30 explicit my_facet(const std::string& nm, std::size_t refs = 0) 31 : F(nm, refs) {} 32}; 33 34int main() 35{ 36 std::ios ios(0); 37 std::ios_base::iostate err; 38 std::tm t; 39 { 40 const my_facet f("en_US", 1); 41 const wchar_t in[] = L"Monday"; 42 err = std::ios_base::goodbit; 43 t = std::tm(); 44 I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t); 45 assert(i.base() == in+sizeof(in)/sizeof(in[0])-1); 46 assert(t.tm_wday == 1); 47 assert(err == std::ios_base::eofbit); 48 } 49 { 50 const my_facet f("fr_FR", 1); 51 const wchar_t in[] = L"Lundi"; 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("ru_RU", 1); 61 const wchar_t in[] = L"\x43F\x43E\x43D\x435\x434\x435\x43B\x44C\x43D\x438\x43A"; 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("zh_CN", 1); 71 const wchar_t in[] = L"\x661F\x671F\x4E00"; 72 err = std::ios_base::goodbit; 73 t = std::tm(); 74 I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t); 75 assert(i.base() == in+sizeof(in)/sizeof(in[0])-1); 76 assert(t.tm_wday == 1); 77 assert(err == std::ios_base::eofbit); 78 } 79} 80