1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // <locale>
10 
11 // class time_get<charT, InputIterator>
12 
13 // iter_type
14 // get_date(iter_type s, iter_type end, ios_base& str,
15 //          ios_base::iostate& err, tm* t) const;
16 
17 #include <locale>
18 #include <cassert>
19 #include <ios>
20 #include "test_macros.h"
21 #include "test_iterators.h"
22 
23 typedef input_iterator<const wchar_t*> I;
24 
25 typedef std::time_get<wchar_t, I> F;
26 
27 class my_facet
28     : public F
29 {
30 public:
my_facet(std::size_t refs=0)31     explicit my_facet(std::size_t refs = 0)
32         : F(refs) {}
33 };
34 
main(int,char **)35 int main(int, char**)
36 {
37     const my_facet f(1);
38     std::ios ios(0);
39     std::ios_base::iostate err;
40     std::tm t;
41     {
42         const wchar_t in[] = L"5/5/5";
43         err = std::ios_base::goodbit;
44         t = std::tm();
45         I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
46         assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
47         assert(t.tm_mon == 4);
48         assert(t.tm_mday == 5);
49         assert(t.tm_year == 105);
50         assert(err == std::ios_base::eofbit);
51     }
52 
53   return 0;
54 }
55