]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/22_locale/ctype/is/char/9858.cc
1 // Copyright (C) 2003-2016 Free Software Foundation, Inc.
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)
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]
22 #include <testsuite_hooks.h>
26 class Derived
: public std::ctype
<char>
30 do_is(mask
, char_type
) const { return true; }
33 do_is(const char_type
*, const char_type
* hi
, mask
*) const
37 do_scan_is(mask
, const char_type
*, const char_type
* hi
) const
41 do_scan_not(mask
, const char_type
*, const char_type
* hi
) const
45 class Derived2
: public Derived
49 do_is(mask
, char_type
) const { called
= 1; return true; }
52 do_is(const char_type
*, const char_type
* hi
, mask
*) const
53 { called
= 5; return hi
; }
56 do_scan_is(mask
, const char_type
*, const char_type
* hi
) const
57 { called
= 10; return hi
; }
60 do_scan_not(mask
, const char_type
*, const char_type
* hi
) const
61 { called
= 15; return hi
; }
67 bool test
__attribute__((unused
)) = true;
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
)
78 dr
.do_is(ctype_base::space
, 'a');
82 dr
.do_is(lit
, lit
+ 5, vec
);
86 dr
.do_scan_is(ctype_base::space
, lit
, lit
+ 5);
87 VERIFY( called
!= 10);
90 dr
.do_scan_not(ctype_base::space
, lit
, lit
+ 5);
91 VERIFY( called
!= 15);