xref: /aosp_15_r20/external/cronet/third_party/libc++/src/test/std/re/re.regex/re.regex.locale/imbue.pass.cpp (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
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, class traits = regex_traits<charT>> class basic_regex;
14 
15 // locale_type imbue(locale_type loc);
16 
17 #include <regex>
18 #include <locale>
19 #include <cassert>
20 
21 #include "test_macros.h"
22 #include "platform_support.h" // locale name macros
23 
main(int,char **)24 int main(int, char**)
25 {
26     std::regex r;
27     std::locale loc = r.imbue(std::locale(LOCALE_en_US_UTF_8));
28     assert(loc.name() == "C");
29     assert(r.getloc().name() == LOCALE_en_US_UTF_8);
30     loc = r.imbue(std::locale("C"));
31     assert(loc.name() == LOCALE_en_US_UTF_8);
32     assert(r.getloc().name() == "C");
33 
34   return 0;
35 }
36