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 // <string>
11 
12 // template<> struct char_traits<wchar_t>
13 
14 // static size_t length(const char_type* s);
15 // constexpr in C++17
16 
17 #include <string>
18 #include <cassert>
19 
20 #include "test_macros.h"
21 
22 #if TEST_STD_VER > 14
test_constexpr()23 constexpr bool test_constexpr()
24 {
25     return std::char_traits<wchar_t>::length(L"") == 0
26         && std::char_traits<wchar_t>::length(L"abcd") == 4;
27 }
28 #endif
29 
main()30 int main()
31 {
32     assert(std::char_traits<wchar_t>::length(L"") == 0);
33     assert(std::char_traits<wchar_t>::length(L"a") == 1);
34     assert(std::char_traits<wchar_t>::length(L"aa") == 2);
35     assert(std::char_traits<wchar_t>::length(L"aaa") == 3);
36     assert(std::char_traits<wchar_t>::length(L"aaaa") == 4);
37 
38 #if TEST_STD_VER > 14
39     static_assert(test_constexpr(), "" );
40 #endif
41 }
42