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_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 "test_iterators.h" 21 22#include "platform_support.h" // locale name macros 23 24typedef input_iterator<const char*> I; 25 26typedef std::time_get_byname<char, 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 char in[] = "June"; 44 err = std::ios_base::goodbit; 45 t = std::tm(); 46 I i = f.get_monthname(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_mon == 5); 49 assert(err == std::ios_base::eofbit); 50 } 51 { 52 const my_facet f(LOCALE_fr_FR_UTF_8, 1); 53 const char in[] = "juin"; 54 err = std::ios_base::goodbit; 55 t = std::tm(); 56 I i = f.get_monthname(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_mon == 5); 59 assert(err == std::ios_base::eofbit); 60 } 61 { 62 const my_facet f(LOCALE_ru_RU_UTF_8, 1); 63 const char in[] = "\xD0\xB8\xD1\x8E\xD0\xBD\xD1\x8F"; 64 err = std::ios_base::goodbit; 65 t = std::tm(); 66 I i = f.get_monthname(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_mon == 5); 69 assert(err == std::ios_base::eofbit); 70 } 71 { 72 const my_facet f(LOCALE_zh_CN_UTF_8, 1); 73 const char in[] = "\xE5\x85\xAD\xE6\x9C\x88"; 74 err = std::ios_base::goodbit; 75 t = std::tm(); 76 I i = f.get_monthname(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_mon == 5); 79 assert(err == std::ios_base::eofbit); 80 } 81} 82