Reverting merge from trunk
[official-gcc.git] / libstdc++-v3 / testsuite / 22_locale / ctype / is / char / 9858.cc
blob0166e09f7119156bc999058f4a60ab0a34809d04
1 // Copyright (C) 2003-2013 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.
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.
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/>.
19 // 22.2.1.3 - ctype specializations [lib.facet.ctype.special]
21 #include <locale>
22 #include <testsuite_hooks.h>
24 int called;
26 class Derived : public std::ctype<char>
28 public:
29 bool
30 do_is(mask, char_type) const { return true; }
32 const char_type*
33 do_is(const char_type*, const char_type* hi, mask*) const
34 { return hi; }
36 const char_type*
37 do_scan_is(mask, const char_type*, const char_type* hi) const
38 { return hi; }
40 const char_type*
41 do_scan_not(mask, const char_type*, const char_type* hi) const
42 { return hi; }
45 class Derived2 : public Derived
47 public:
48 bool
49 do_is(mask, char_type) const { called = 1; return true; }
51 const char_type*
52 do_is(const char_type*, const char_type* hi, mask*) const
53 { called = 5; return hi; }
55 const char_type*
56 do_scan_is(mask, const char_type*, const char_type* hi) const
57 { called = 10; return hi; }
59 const char_type*
60 do_scan_not(mask, const char_type*, const char_type* hi) const
61 { called = 15; return hi; }
64 int main()
66 using namespace std;
67 bool test __attribute__((unused)) = true;
68 Derived2 d2;
69 const Derived& dr = d2;
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;
77 called = 0;
78 dr.do_is(ctype_base::space, 'a');
79 VERIFY( called != 1);
81 called = 0;
82 dr.do_is(lit, lit + 5, vec);
83 VERIFY( called != 5);
85 called = 0;
86 dr.do_scan_is(ctype_base::space, lit, lit + 5);
87 VERIFY( called != 10);
89 called = 0;
90 dr.do_scan_not(ctype_base::space, lit, lit + 5);
91 VERIFY( called != 15);
93 return 0;