xref: /llvm-project/libcxx/test/std/re/re.traits/getloc.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 // REQUIRES: locale.en_US.UTF-8
10 
11 // <regex>
12 
13 // template <class charT> struct regex_traits;
14 
15 // locale_type getloc()const;
16 
17 #include <regex>
18 #include <cassert>
19 
20 #include "test_macros.h"
21 #include "platform_support.h" // locale name macros
22 
main(int,char **)23 int main(int, char**)
24 {
25     {
26         std::regex_traits<char> t;
27         assert(t.getloc().name() == "C");
28     }
29 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
30     {
31         std::regex_traits<wchar_t> t;
32         assert(t.getloc().name() == "C");
33     }
34 #endif
35     {
36         std::locale::global(std::locale(LOCALE_en_US_UTF_8));
37         std::regex_traits<char> t;
38         assert(t.getloc().name() == LOCALE_en_US_UTF_8);
39     }
40 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
41     {
42         std::locale::global(std::locale(LOCALE_en_US_UTF_8));
43         std::regex_traits<wchar_t> t;
44         assert(t.getloc().name() == LOCALE_en_US_UTF_8);
45     }
46 #endif
47 
48   return 0;
49 }
50