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 13 // <locale> 14 15 // template <class CharT, class OutputIterator = ostreambuf_iterator<CharT> > 16 // class time_put_byname 17 // : public time_put<CharT, OutputIterator> 18 // { 19 // public: 20 // explicit time_put_byname(const char* nm, size_t refs = 0); 21 // explicit time_put_byname(const string& nm, size_t refs = 0); 22 // 23 // protected: 24 // ~time_put_byname(); 25 // }; 26 27 // TODO: investigation needed 28 // XFAIL: linux-gnu 29 30 #include <locale> 31 #include <cassert> 32 #include "test_iterators.h" 33 34 #include "platform_support.h" // locale name macros 35 36 typedef std::time_put_byname<char, output_iterator<char*> > F; 37 38 class my_facet 39 : public F 40 { 41 public: 42 explicit my_facet(const std::string& nm, std::size_t refs = 0) 43 : F(nm, refs) {} 44 }; 45 46 int main() 47 { 48 char str[200]; 49 output_iterator<char*> iter; 50 tm t; 51 t.tm_sec = 6; 52 t.tm_min = 3; 53 t.tm_hour = 13; 54 t.tm_mday = 2; 55 t.tm_mon = 4; 56 t.tm_year = 109; 57 t.tm_wday = 6; 58 t.tm_yday = -1; 59 t.tm_isdst = 1; 60 std::ios ios(0); 61 { 62 const my_facet f(LOCALE_en_US_UTF_8, 1); 63 std::string pat("Today is %A which is abbreviated %a."); 64 iter = f.put(output_iterator<char*>(str), ios, '*', &t, 65 pat.data(), pat.data() + pat.size()); 66 std::string ex(str, iter.base()); 67 assert(ex == "Today is Saturday which is abbreviated Sat."); 68 } 69 { 70 const my_facet f(LOCALE_fr_FR_UTF_8, 1); 71 std::string pat("Today is %A which is abbreviated %a."); 72 iter = f.put(output_iterator<char*>(str), ios, '*', &t, 73 pat.data(), pat.data() + pat.size()); 74 std::string ex(str, iter.base()); 75 assert((ex == "Today is Samedi which is abbreviated Sam.")|| 76 (ex == "Today is samedi which is abbreviated sam." )); 77 } 78 } 79