Merge pull request #171 from pefoley2/lto
[dyninst.git] / cmake / CheckCXX11Features / cxx11-test-regex.cpp
1 #include <algorithm>
2 #include <regex>
3
4 int parse_line(std::string const& line)
5 {
6         std::string tmp;
7         if(std::regex_search(line, std::regex("(\\s)+(-)?(\\d)+//(-)?(\\d)+(\\s)+"))) {
8                 tmp = std::regex_replace(line, std::regex("(-)?(\\d)+//(-)?(\\d)+"), std::string("V"));
9         } else if(std::regex_search(line, std::regex("(\\s)+(-)?(\\d)+/(-)?(\\d)+(\\s)+"))) {
10                 tmp = std::regex_replace(line, std::regex("(-)?(\\d)+/(-)?(\\d)+"), std::string("V"));
11         } else if(std::regex_search(line, std::regex("(\\s)+(-)?(\\d)+/(-)?(\\d)+/(-)?(\\d)+(\\s)+"))) {
12                 tmp = std::regex_replace(line, std::regex("(-)?(\\d)+/(-)?(\\d)+/(-)?(\\d)+"), std::string("V"));
13         } else {
14                 tmp = std::regex_replace(line, std::regex("(-)?(\\d)+"), std::string("V"));
15         }
16         return static_cast<int>(std::count(tmp.begin(), tmp.end(), 'V'));
17 }
18
19 int main()
20 {
21         bool test = (parse_line("f 7/7/7 -3/3/-3 2/-2/2") == 3) &&
22                                 (parse_line("f 7//7 3//-3 -2//2") == 3) &&
23                                 (parse_line("f 7/7 3/-3 -2/2") == 3) &&
24                                 (parse_line("f 7 3 -2") == 3);
25         return test ? 0 : 1;
26 }