xref: /llvm-project/libcxx/test/std/re/re.traits/length.pass.cpp (revision f4c1258d5633fcf06385ff3fd1f4bf57ab971964)
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 // <regex>
10 
11 // template <class charT> struct regex_traits;
12 
13 // static std::size_t length(const char_type* p);
14 
15 #include <regex>
16 #include <cassert>
17 #include "test_macros.h"
18 
main(int,char **)19 int main(int, char**)
20 {
21     assert(std::regex_traits<char>::length("") == 0);
22     assert(std::regex_traits<char>::length("1") == 1);
23     assert(std::regex_traits<char>::length("12") == 2);
24     assert(std::regex_traits<char>::length("123") == 3);
25 
26 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
27     assert(std::regex_traits<wchar_t>::length(L"") == 0);
28     assert(std::regex_traits<wchar_t>::length(L"1") == 1);
29     assert(std::regex_traits<wchar_t>::length(L"12") == 2);
30     assert(std::regex_traits<wchar_t>::length(L"123") == 3);
31 #endif
32 
33   return 0;
34 }
35