]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/28_regex/constants/syntax_option_type.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 28_regex / constants / syntax_option_type.cc
1 // { dg-do run { target c++11 } }
2 // { dg-timeout-factor 2 }
3 //
4 // 2009-06-17 Stephen M. Webb <stephen.webb@xandros.com>
5 //
6 // Copyright (C) 2009-2024 Free Software Foundation, Inc.
7 //
8 // This file is part of the GNU ISO C++ Library. This library is free
9 // software; you can redistribute it and/or modify it under the
10 // terms of the GNU General Public License as published by the
11 // Free Software Foundation; either version 3, or (at your option)
12 // any later version.
13 //
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License along
20 // with this library; see the file COPYING3. If not see
21 // <http://www.gnu.org/licenses/>.
22
23 // C++11 28.5.1 [re.synopt]
24
25 #include <regex>
26 #include <testsuite_hooks.h>
27 #include <testsuite_common_types.h>
28
29 void
30 test01()
31 {
32 std::regex_constants::syntax_option_type option { };
33 option = option | std::regex_constants::icase;
34 option = option | std::regex_constants::nosubs;
35 option = option | std::regex_constants::optimize;
36 option = option | std::regex_constants::collate;
37 option = option | std::regex_constants::ECMAScript;
38 option = option | std::regex_constants::basic;
39 option = option | std::regex_constants::extended;
40 option = option | std::regex_constants::awk;
41 option = option | std::regex_constants::grep;
42 option = option | std::regex_constants::egrep;
43 }
44
45 void
46 test02()
47 {
48 std::regex_constants::syntax_option_type option { };
49 option = option & std::regex_constants::icase;
50 option = option & std::regex_constants::nosubs;
51 option = option & std::regex_constants::optimize;
52 option = option & std::regex_constants::collate;
53 option = option & std::regex_constants::ECMAScript;
54 option = option & std::regex_constants::basic;
55 option = option & std::regex_constants::extended;
56 option = option & std::regex_constants::awk;
57 option = option & std::regex_constants::grep;
58 option = option & std::regex_constants::egrep;
59 }
60
61 void
62 test03()
63 {
64 std::regex_constants::syntax_option_type option { };
65 option = ~std::regex_constants::icase;
66 option = ~std::regex_constants::nosubs;
67 option = ~std::regex_constants::optimize;
68 option = ~std::regex_constants::collate;
69 option = ~std::regex_constants::ECMAScript;
70 option = ~std::regex_constants::basic;
71 option = ~std::regex_constants::extended;
72 option = ~std::regex_constants::awk;
73 option = ~std::regex_constants::grep;
74 option = ~std::regex_constants::egrep;
75 option = option;
76 }
77
78 void
79 test04_constexpr()
80 {
81 using namespace std::regex_constants;
82 constexpr auto a1 __attribute__((unused)) = icase | awk;
83 constexpr auto a2 __attribute__((unused)) = icase & awk;
84 constexpr auto a3 __attribute__((unused)) = ~grep;
85 }
86
87 void
88 test05()
89 {
90 using namespace std;
91 using namespace regex_constants;
92 regex re("((a)(s))", nosubs | ECMAScript);
93 VERIFY(re.mark_count() == 0);
94 }
95
96 #if __cplusplus >= 201402L
97 static_assert(
98 __gnu_test::test_bitmask_values( {
99 std::regex_constants::icase,
100 std::regex_constants::nosubs,
101 std::regex_constants::optimize,
102 std::regex_constants::collate,
103 std::regex_constants::ECMAScript,
104 std::regex_constants::basic,
105 std::regex_constants::extended,
106 std::regex_constants::awk,
107 std::regex_constants::grep,
108 std::regex_constants::egrep,
109 std::regex_constants::__multiline,
110 std::regex_constants::__polynomial
111 }, {
112 #if __cplusplus >= 201703L
113 std::regex_constants::multiline // equal to __multiline
114 #endif
115 }),
116 "std::regex_constants::syntax_option_type bitmask elements are distinct" );
117 #endif
118
119 int main()
120 {
121 test01();
122 test02();
123 test03();
124 test04_constexpr();
125 test05();
126 return 0;
127 }