• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // <regex>
11 // UNSUPPORTED: c++98, c++03
12 
13 // Make sure that we correctly match inverted character classes.
14 
15 #include <cassert>
16 #include <regex>
17 
18 
main()19 int main() {
20     assert(std::regex_match("X", std::regex("[X]")));
21     assert(std::regex_match("X", std::regex("[XY]")));
22     assert(!std::regex_match("X", std::regex("[^X]")));
23     assert(!std::regex_match("X", std::regex("[^XY]")));
24 
25     assert(std::regex_match("X", std::regex("[\\S]")));
26     assert(!std::regex_match("X", std::regex("[^\\S]")));
27 
28     assert(!std::regex_match("X", std::regex("[\\s]")));
29     assert(std::regex_match("X", std::regex("[^\\s]")));
30 
31     assert(std::regex_match("X", std::regex("[\\s\\S]")));
32     assert(std::regex_match("X", std::regex("[^Y\\s]")));
33     assert(!std::regex_match("X", std::regex("[^X\\s]")));
34 
35     assert(std::regex_match("X", std::regex("[\\w]")));
36     assert(std::regex_match("_", std::regex("[\\w]")));
37     assert(!std::regex_match("X", std::regex("[^\\w]")));
38     assert(!std::regex_match("_", std::regex("[^\\w]")));
39 
40     assert(!std::regex_match("X", std::regex("[\\W]")));
41     assert(!std::regex_match("_", std::regex("[\\W]")));
42     assert(std::regex_match("X", std::regex("[^\\W]")));
43     assert(std::regex_match("_", std::regex("[^\\W]")));
44 }
45