get_date.pass.cpp revision 83e2c4d877fe2d7793868b1c6a5d9525a7c4d431
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<charT, InputIterator> 13 14// iter_type 15// get_date(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 22typedef input_iterator<const char*> I; 23 24typedef std::time_get<char, I> F; 25 26class my_facet 27 : public F 28{ 29public: 30 explicit my_facet(std::size_t refs = 0) 31 : F(refs) {} 32}; 33 34int main() 35{ 36 const my_facet f(1); 37 std::ios ios(0); 38 std::ios_base::iostate err; 39 std::tm t; 40 { 41 const char in[] = "5/5/5"; 42 err = std::ios_base::goodbit; 43 t = std::tm(); 44 I i = f.get_date(I(in), I(in+sizeof(in)-1), ios, err, &t); 45 assert(i.base() == in+sizeof(in)-1); 46 assert(t.tm_mon == 4); 47 assert(t.tm_mday == 5); 48 assert(t.tm_year == 105); 49 assert(err == std::ios_base::eofbit); 50 } 51} 52