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