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 
22 typedef input_iterator<const wchar_t*> I;
23 
24 typedef std::time_get<wchar_t, I> F;
25 
26 class my_facet
27     : public F
28 {
29 public:
30     explicit my_facet(std::size_t refs = 0)
31         : F(refs) {}
32 };
33 
34 int 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 wchar_t in[] = L"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)/sizeof(in[0])-1), ios, err, &t);
45         assert(i.base() == in+sizeof(in)/sizeof(in[0])-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