get_monthname_wide.pass.cpp revision f5256e16dfc425c1d466f6308d4026d529ce9e0b
1//===----------------------------------------------------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10// <locale> 11 12// class time_get_byname<charT, InputIterator> 13 14// iter_type 15// get_monthname(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 34typedef std::time_put_byname<wchar_t, wchar_t*> F2; 35class my_facet2 36 : public F2 37{ 38public: 39 explicit my_facet2(const std::string& nm, std::size_t refs = 0) 40 : F2(nm, refs) {} 41}; 42 43int main() 44{ 45 std::ios ios(0); 46 std::ios_base::iostate err; 47 std::tm t; 48 { 49 const my_facet f("en_US", 1); 50 const wchar_t in[] = L"June"; 51 err = std::ios_base::goodbit; 52 t = std::tm(); 53 I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t); 54 assert(i.base() == in+sizeof(in)/sizeof(in[0])-1); 55 assert(t.tm_mon == 5); 56 assert(err == std::ios_base::eofbit); 57 } 58 { 59 const my_facet f("fr_FR", 1); 60 const wchar_t in[] = L"juin"; 61 err = std::ios_base::goodbit; 62 t = std::tm(); 63 I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t); 64 assert(i.base() == in+sizeof(in)/sizeof(in[0])-1); 65 assert(t.tm_mon == 5); 66 assert(err == std::ios_base::eofbit); 67 } 68 { 69 const my_facet f("ru_RU", 1); 70 const wchar_t in[] = L"\x438\x44E\x43D\x44F"; 71 err = std::ios_base::goodbit; 72 t = std::tm(); 73 I i = f.get_monthname(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_mon == 5); 76 assert(err == std::ios_base::eofbit); 77 } 78 { 79 const my_facet f("zh_CN", 1); 80 const wchar_t in[] = L"\x516D\x6708"; 81 err = std::ios_base::goodbit; 82 t = std::tm(); 83 I i = f.get_monthname(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_mon == 5); 86 assert(err == std::ios_base::eofbit); 87 } 88} 89