55 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// REQUIRES: locale.en_US.UTF-810// REQUIRES: locale.fr_FR.UTF-811 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 macros25 26template <class CharT>27struct test28 : public std::basic_streambuf<CharT>29{30 test() {}31 32 void imbue(const std::locale&)33 {34 assert(this->getloc().name() == LOCALE_en_US_UTF_8);35 }36};37 38int 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