1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // REQUIRES: locale.en_US.UTF-8
13 // template <class charT, class traits> class basic_ios
15 // locale imbue(const locale& loc);
21 #include "test_macros.h"
22 #include "platform_support.h" // locale name macros
25 : public std::streambuf
29 bool f1_called
= false;
30 bool f2_called
= false;
31 bool f3_called
= false;
33 void f1(std::ios_base::event ev
, std::ios_base
& stream
, int index
)
35 if (ev
== std::ios_base::imbue_event
)
40 assert(stream
.getloc().name() == LOCALE_en_US_UTF_8
);
46 void f2(std::ios_base::event ev
, std::ios_base
& stream
, int index
)
48 if (ev
== std::ios_base::imbue_event
)
53 assert(stream
.getloc().name() == LOCALE_en_US_UTF_8
);
59 void f3(std::ios_base::event ev
, std::ios_base
& stream
, int index
)
61 if (ev
== std::ios_base::imbue_event
)
66 assert(stream
.getloc().name() == LOCALE_en_US_UTF_8
);
76 ios
.register_callback(f1
, 4);
77 ios
.register_callback(f2
, 5);
78 ios
.register_callback(f3
, 6);
79 std::locale l
= ios
.imbue(std::locale(LOCALE_en_US_UTF_8
));
80 assert(l
.name() == std::string("C"));
81 assert(ios
.getloc().name() == std::string(LOCALE_en_US_UTF_8
));
92 ios
.register_callback(f1
, 4);
93 ios
.register_callback(f2
, 5);
94 ios
.register_callback(f3
, 6);
95 std::locale l
= ios
.imbue(std::locale(LOCALE_en_US_UTF_8
));
96 assert(l
.name() == std::string("C"));
97 assert(ios
.getloc().name() == std::string(LOCALE_en_US_UTF_8
));
98 assert(sb
.getloc().name() == std::string(LOCALE_en_US_UTF_8
));