]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/22_locale/ctype/is/char/9858.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 22_locale / ctype / is / char / 9858.cc
CommitLineData
8d9254fc 1// Copyright (C) 2003-2020 Free Software Foundation, Inc.
82c2e3d4
BK
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
748086b7 6// Free Software Foundation; either version 3, or (at your option)
82c2e3d4
BK
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
748086b7
JJ
15// with this library; see the file COPYING3. If not see
16// <http://www.gnu.org/licenses/>.
17
82c2e3d4
BK
18
19// 22.2.1.3 - ctype specializations [lib.facet.ctype.special]
20
21#include <locale>
22#include <testsuite_hooks.h>
23
24int called;
25
26class Derived : public std::ctype<char>
27{
28public:
29 bool
30 do_is(mask, char_type) const { return true; }
31
32 const char_type*
8b5bc374 33 do_is(const char_type*, const char_type* hi, mask*) const
82c2e3d4
BK
34 { return hi; }
35
36 const char_type*
8b5bc374 37 do_scan_is(mask, const char_type*, const char_type* hi) const
82c2e3d4
BK
38 { return hi; }
39
40 const char_type*
8b5bc374 41 do_scan_not(mask, const char_type*, const char_type* hi) const
82c2e3d4
BK
42 { return hi; }
43};
44
45class Derived2 : public Derived
46{
47public:
48 bool
49 do_is(mask, char_type) const { called = 1; return true; }
50
51 const char_type*
8b5bc374 52 do_is(const char_type*, const char_type* hi, mask*) const
82c2e3d4
BK
53 { called = 5; return hi; }
54
55 const char_type*
8b5bc374 56 do_scan_is(mask, const char_type*, const char_type* hi) const
82c2e3d4
BK
57 { called = 10; return hi; }
58
59 const char_type*
8b5bc374 60 do_scan_not(mask, const char_type*, const char_type* hi) const
82c2e3d4
BK
61 { called = 15; return hi; }
62};
63
64int main()
65{
66 using namespace std;
82c2e3d4
BK
67 Derived2 d2;
68 const Derived& dr = d2;
69
70 const char* lit = "jaylib champion sound";
71 ctype_base::mask m00 = static_cast<std::ctype_base::mask>(0);
72 ctype_base::mask vec[5];
73 for (std::size_t i = 0; i < 5; ++i)
74 vec[i] = m00;
75
76 called = 0;
77 dr.do_is(ctype_base::space, 'a');
78 VERIFY( called != 1);
79
80 called = 0;
81 dr.do_is(lit, lit + 5, vec);
82 VERIFY( called != 5);
83
84 called = 0;
85 dr.do_scan_is(ctype_base::space, lit, lit + 5);
86 VERIFY( called != 10);
87
88 called = 0;
89 dr.do_scan_not(ctype_base::space, lit, lit + 5);
90 VERIFY( called != 15);
91
92 return 0;
93}