xref: /aosp_15_r20/external/cronet/third_party/libc++/src/test/std/re/re.const/re.synopt/syntax_option_type.pass.cpp (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // <regex>
10 
11 // namespace regex_constants
12 // {
13 //
14 // enum syntax_option_type  // bitmask type
15 // {
16 //     icase      = unspecified,
17 //     nosubs     = unspecified,
18 //     optimize   = unspecified,
19 //     collate    = unspecified,
20 //     ECMAScript = unspecified,
21 //     basic      = unspecified,
22 //     extended   = unspecified,
23 //     awk        = unspecified,
24 //     grep       = unspecified,
25 //     egrep      = unspecified,
26 //     multiline  = unspecified
27 // };
28 //
29 // }
30 
31 #include <regex>
32 #include <cassert>
33 #include "test_macros.h"
34 
main(int,char **)35 int main(int, char**)
36 {
37     assert(std::regex_constants::icase != 0);
38     assert(std::regex_constants::nosubs != 0);
39     assert(std::regex_constants::optimize != 0);
40     assert(std::regex_constants::collate != 0);
41 #if !defined _LIBCPP_VERSION || defined _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO
42     // https://llvm.org/PR35967
43     assert(std::regex_constants::ECMAScript != 0);
44 #else
45     assert(std::regex_constants::ECMAScript == 0);
46 #endif
47     assert(std::regex_constants::basic != 0);
48     assert(std::regex_constants::extended != 0);
49     assert(std::regex_constants::awk != 0);
50     assert(std::regex_constants::grep != 0);
51     assert(std::regex_constants::egrep != 0);
52     assert(std::regex_constants::multiline != 0);
53 
54     assert((std::regex_constants::icase & std::regex_constants::nosubs) == 0);
55     assert((std::regex_constants::icase & std::regex_constants::optimize) == 0);
56     assert((std::regex_constants::icase & std::regex_constants::collate) == 0);
57     assert((std::regex_constants::icase & std::regex_constants::ECMAScript) == 0);
58     assert((std::regex_constants::icase & std::regex_constants::basic) == 0);
59     assert((std::regex_constants::icase & std::regex_constants::extended) == 0);
60     assert((std::regex_constants::icase & std::regex_constants::awk) == 0);
61     assert((std::regex_constants::icase & std::regex_constants::grep) == 0);
62     assert((std::regex_constants::icase & std::regex_constants::egrep) == 0);
63     assert((std::regex_constants::icase & std::regex_constants::multiline) == 0);
64 
65     assert((std::regex_constants::nosubs & std::regex_constants::optimize) == 0);
66     assert((std::regex_constants::nosubs & std::regex_constants::collate) == 0);
67     assert((std::regex_constants::nosubs & std::regex_constants::ECMAScript) == 0);
68     assert((std::regex_constants::nosubs & std::regex_constants::basic) == 0);
69     assert((std::regex_constants::nosubs & std::regex_constants::extended) == 0);
70     assert((std::regex_constants::nosubs & std::regex_constants::awk) == 0);
71     assert((std::regex_constants::nosubs & std::regex_constants::grep) == 0);
72     assert((std::regex_constants::nosubs & std::regex_constants::egrep) == 0);
73     assert((std::regex_constants::nosubs & std::regex_constants::multiline) == 0);
74 
75     assert((std::regex_constants::optimize & std::regex_constants::collate) == 0);
76     assert((std::regex_constants::optimize & std::regex_constants::ECMAScript) == 0);
77     assert((std::regex_constants::optimize & std::regex_constants::basic) == 0);
78     assert((std::regex_constants::optimize & std::regex_constants::extended) == 0);
79     assert((std::regex_constants::optimize & std::regex_constants::awk) == 0);
80     assert((std::regex_constants::optimize & std::regex_constants::grep) == 0);
81     assert((std::regex_constants::optimize & std::regex_constants::egrep) == 0);
82     assert((std::regex_constants::optimize & std::regex_constants::multiline) == 0);
83 
84     assert((std::regex_constants::collate & std::regex_constants::ECMAScript) == 0);
85     assert((std::regex_constants::collate & std::regex_constants::basic) == 0);
86     assert((std::regex_constants::collate & std::regex_constants::extended) == 0);
87     assert((std::regex_constants::collate & std::regex_constants::awk) == 0);
88     assert((std::regex_constants::collate & std::regex_constants::grep) == 0);
89     assert((std::regex_constants::collate & std::regex_constants::egrep) == 0);
90     assert((std::regex_constants::collate & std::regex_constants::multiline) == 0);
91 
92     assert((std::regex_constants::ECMAScript & std::regex_constants::basic) == 0);
93     assert((std::regex_constants::ECMAScript & std::regex_constants::extended) == 0);
94     assert((std::regex_constants::ECMAScript & std::regex_constants::awk) == 0);
95     assert((std::regex_constants::ECMAScript & std::regex_constants::grep) == 0);
96     assert((std::regex_constants::ECMAScript & std::regex_constants::egrep) == 0);
97     assert((std::regex_constants::ECMAScript & std::regex_constants::multiline) == 0);
98 
99     assert((std::regex_constants::basic & std::regex_constants::extended) == 0);
100     assert((std::regex_constants::basic & std::regex_constants::awk) == 0);
101     assert((std::regex_constants::basic & std::regex_constants::grep) == 0);
102     assert((std::regex_constants::basic & std::regex_constants::egrep) == 0);
103     assert((std::regex_constants::basic & std::regex_constants::multiline) == 0);
104 
105     assert((std::regex_constants::extended & std::regex_constants::awk) == 0);
106     assert((std::regex_constants::extended & std::regex_constants::grep) == 0);
107     assert((std::regex_constants::extended & std::regex_constants::egrep) == 0);
108     assert((std::regex_constants::extended & std::regex_constants::multiline) == 0);
109 
110     assert((std::regex_constants::awk & std::regex_constants::grep) == 0);
111     assert((std::regex_constants::awk & std::regex_constants::egrep) == 0);
112     assert((std::regex_constants::awk & std::regex_constants::multiline) == 0);
113 
114     assert((std::regex_constants::grep & std::regex_constants::egrep) == 0);
115     assert((std::regex_constants::grep & std::regex_constants::multiline) == 0);
116 
117     assert((std::regex_constants::egrep & std::regex_constants::multiline) == 0);
118 
119     assert((std::regex_constants::icase | std::regex_constants::nosubs) != 0);
120     assert((std::regex_constants::icase ^ std::regex_constants::nosubs) != 0);
121 
122     std::regex_constants::syntax_option_type e1 = std::regex_constants::icase;
123     std::regex_constants::syntax_option_type e2 = std::regex_constants::nosubs;
124     e1 = ~e1;
125     e1 = e1 & e2;
126     e1 = e1 | e2;
127     e1 = e1 ^ e2;
128     e1 &= e2;
129     e1 |= e2;
130     e1 ^= e2;
131 
132   return 0;
133 }
134