locales.pass.cpp revision a824f536004806c079b3b1dacdb5e1ef5bd533f9
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// <streambuf>
11
12// template <class charT, class traits = char_traits<charT> >
13// class basic_streambuf;
14
15// locale pubimbue(const locale& loc);
16// locale getloc() const;
17
18#include <streambuf>
19#include <cassert>
20
21template <class CharT>
22struct test
23    : public std::basic_streambuf<CharT>
24{
25    test() {}
26
27    void imbue(const std::locale&)
28    {
29        assert(this->getloc().name() == "en_US.UTF-8");
30    }
31};
32
33int main()
34{
35    {
36        test<char> t;
37        assert(t.getloc().name() == "C");
38    }
39    std::locale::global(std::locale("en_US.UTF-8"));
40    {
41        test<char> t;
42        assert(t.getloc().name() == "en_US.UTF-8");
43        assert(t.pubimbue(std::locale("fr_FR.UTF-8")).name() == "en_US.UTF-8");
44        assert(t.getloc().name() == "fr_FR.UTF-8");
45    }
46}
47