locales.pass.cpp revision f5256e16dfc425c1d466f6308d4026d529ce9e0b
1//===----------------------------------------------------------------------===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. 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");
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"));
40    {
41        test<char> t;
42        assert(t.getloc().name() == "en_US");
43        assert(t.pubimbue(std::locale("fr_FR")).name() == "en_US");
44        assert(t.getloc().name() == "fr_FR");
45    }
46}
47