]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/28_regex/traits/char/isctype.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 28_regex / traits / char / isctype.cc
1 // { dg-do run { target c++11 } }
2 // { dg-additional-options "-DNEWLINE_IN_CLASS_BLANK" { target newlib } }
3
4 //
5 // 2010-06-23 Stephen M. Webb <stephen.webb@bregmasoft.ca>
6 //
7 // Copyright (C) 2010-2019 Free Software Foundation, Inc.
8 //
9 // This file is part of the GNU ISO C++ Library. This library is free
10 // software; you can redistribute it and/or modify it under the
11 // terms of the GNU General Public License as published by the
12 // Free Software Foundation; either version 3, or (at your option)
13 // any later version.
14 //
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License along
21 // with this library; see the file COPYING3. If not see
22 // <http://www.gnu.org/licenses/>.
23
24 // 28.3 Requirements [re.req]
25 // 28.2(4) Table 127 - Regular expression traits class requirements
26 // 28.7(11) Class template regex_traits [re.traits]
27
28 #include <regex>
29 #include <testsuite_hooks.h>
30
31 void
32 test01()
33 {
34 typedef char CharT;
35 typedef std::regex_traits<CharT> traits;
36
37 const CharT lower[] = "lOWer";
38 const CharT upper[] = "UPPER";
39 const CharT nothing[] = "nothing";
40 const CharT word[] = "w";
41 const CharT blank[] = "blank";
42 const CharT digit[] = "digit";
43 traits t;
44
45 #define range(s) s, s+sizeof(s)/sizeof(s[0])-1
46 VERIFY( t.isctype('_', t.lookup_classname(range(word))));
47 VERIFY( t.isctype('A', t.lookup_classname(range(word))));
48 VERIFY(!t.isctype('~', t.lookup_classname(range(word))));
49 VERIFY(!t.isctype('e', t.lookup_classname(range(upper))));
50 VERIFY( t.isctype('e', t.lookup_classname(range(lower))));
51 VERIFY(!t.isctype('e', t.lookup_classname(range(nothing))));
52 VERIFY(!t.isctype('_', t.lookup_classname(range(digit))));
53 VERIFY( t.isctype(' ', t.lookup_classname(range(blank))));
54 VERIFY( t.isctype('\t', t.lookup_classname(range(blank))));
55 #if !defined (NEWLINE_IN_CLASS_BLANK)
56 VERIFY(!t.isctype('\n', t.lookup_classname(range(blank))));
57 #endif
58 VERIFY( t.isctype('t', t.lookup_classname(range(upper), true)));
59 VERIFY( t.isctype('T', t.lookup_classname(range(lower), true)));
60 #undef range
61 }
62
63 int main()
64 {
65 test01();
66 return 0;
67 }