Debian Codegraph @

libstdc++-v3/testsuite/27_io/basic_ios/fill/wchar_t/1.cc

raw
1 // { dg-do run }
2
3 #include <ios>
4 #include <locale>
5 #include <streambuf>
6 #include <testsuite_hooks.h>
7
8 typedef wchar_t C;
9
10 struct tabby_mctype : std::ctype<C>
11 {
12 C do_widen(char c) const { return c == ' ' ? L'\t' : c; }
13
14 const char*
15 do_widen(const char* lo, const char* hi, C* to) const
16 {
17 while (lo != hi)
18 *to++ = do_widen(*lo++);
19 return hi;
20 }
21 };
22
23 void
24 test01()
25 {
26 std::basic_ios<C> out(0);
27 std::locale loc(std::locale(), new tabby_mctype);
28 out.imbue(loc);
29 VERIFY( out.fill() == L' ' ); // Imbuing a new locale doesn't affect fill().
30 out.fill(L'*');
31 VERIFY( out.fill() == L'*' ); // This will be cached now.
32 out.imbue(std::locale());
33 VERIFY( out.fill() == L'*' ); // Imbuing a new locale doesn't affect fill().
34 }
35
36 void
37 test02()
38 {
39 std::locale loc(std::locale(), new tabby_mctype);
40 std::locale::global(loc);
41 std::basic_ios<C> out(0);
42 VERIFY( out.fill() == L'\t' );
43 out.imbue(std::locale::classic());
44 VERIFY( out.fill() == L'\t' ); // Imbuing a new locale doesn't affect fill().
45 out.fill(L'*');
46 VERIFY( out.fill() == L'*' ); // This will be cached now.
47 out.imbue(std::locale());
48 VERIFY( out.fill() == L'*' ); // Imbuing a new locale doesn't affect fill().
49 }
50
51 int main()
52 {
53 test01();
54 test02();
55 }