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 // REQUIRES: locale.fr_FR.UTF-8
11 
12 // <streambuf>
13 
14 // template <class charT, class traits = char_traits<charT> >
15 // class basic_streambuf;
16 
17 // locale pubimbue(const locale& loc);
18 // locale getloc() const;
19 
20 #include <streambuf>
21 #include <cassert>
22 
23 #include "test_macros.h"
24 #include "platform_support.h" // locale name macros
25 
26 template <class CharT>
27 struct test
28     : public std::basic_streambuf<CharT>
29 {
testtest30     test() {}
31 
imbuetest32     void imbue(const std::locale&)
33     {
34         assert(this->getloc().name() == LOCALE_en_US_UTF_8);
35     }
36 };
37 
main(int,char **)38 int main(int, char**)
39 {
40     {
41         test<char> t;
42         assert(t.getloc().name() == "C");
43     }
44     std::locale::global(std::locale(LOCALE_en_US_UTF_8));
45     {
46         test<char> t;
47         assert(t.getloc().name() == LOCALE_en_US_UTF_8);
48         assert(t.pubimbue(std::locale(LOCALE_fr_FR_UTF_8)).name() ==
49                LOCALE_en_US_UTF_8);
50         assert(t.getloc().name() == LOCALE_fr_FR_UTF_8);
51     }
52 
53   return 0;
54 }
55