]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/22_locale/ctype/is/char/9858.cc
Update copyright years in libstdc++-v3/
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 22_locale / ctype / is / char / 9858.cc
1 // Copyright (C) 2003-2014 Free Software Foundation, Inc.
2 //
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
7 // any later version.
8
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
17
18
19 // 22.2.1.3 - ctype specializations [lib.facet.ctype.special]
20
21 #include <locale>
22 #include <testsuite_hooks.h>
23
24 int called;
25
26 class Derived : public std::ctype<char>
27 {
28 public:
29 bool
30 do_is(mask, char_type) const { return true; }
31
32 const char_type*
33 do_is(const char_type*, const char_type* hi, mask*) const
34 { return hi; }
35
36 const char_type*
37 do_scan_is(mask, const char_type*, const char_type* hi) const
38 { return hi; }
39
40 const char_type*
41 do_scan_not(mask, const char_type*, const char_type* hi) const
42 { return hi; }
43 };
44
45 class Derived2 : public Derived
46 {
47 public:
48 bool
49 do_is(mask, char_type) const { called = 1; return true; }
50
51 const char_type*
52 do_is(const char_type*, const char_type* hi, mask*) const
53 { called = 5; return hi; }
54
55 const char_type*
56 do_scan_is(mask, const char_type*, const char_type* hi) const
57 { called = 10; return hi; }
58
59 const char_type*
60 do_scan_not(mask, const char_type*, const char_type* hi) const
61 { called = 15; return hi; }
62 };
63
64 int main()
65 {
66 using namespace std;
67 bool test __attribute__((unused)) = true;
68 Derived2 d2;
69 const Derived& dr = d2;
70
71 const char* lit = "jaylib champion sound";
72 ctype_base::mask m00 = static_cast<std::ctype_base::mask>(0);
73 ctype_base::mask vec[5];
74 for (std::size_t i = 0; i < 5; ++i)
75 vec[i] = m00;
76
77 called = 0;
78 dr.do_is(ctype_base::space, 'a');
79 VERIFY( called != 1);
80
81 called = 0;
82 dr.do_is(lit, lit + 5, vec);
83 VERIFY( called != 5);
84
85 called = 0;
86 dr.do_scan_is(ctype_base::space, lit, lit + 5);
87 VERIFY( called != 10);
88
89 called = 0;
90 dr.do_scan_not(ctype_base::space, lit, lit + 5);
91 VERIFY( called != 15);
92
93 return 0;
94 }