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 // REQUIRES: locale.en_US.UTF-8
11 // REQUIRES: locale.fr_FR.UTF-8
12 
13 // <streambuf>
14 
15 // template <class charT, class traits = char_traits<charT> >
16 // class basic_streambuf;
17 
18 // locale pubimbue(const locale& loc);
19 // locale getloc() const;
20 
21 #include <streambuf>
22 #include <cassert>
23 
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()38 int main()
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