Macros | Functions | Variables
regex_t.cc File Reference
#include "boost/test/unit_test.hpp"
#include "cetlib/LibraryManager.h"
#include <fstream>
#include <iostream>
#include <regex>
#include <string>
#include <vector>

Go to the source code of this file.

Macros

#define BOOST_TEST_MODULE   (regex test)
 

Functions

 BOOST_TEST_REQUIRE (static_cast< bool >(inFile))
 
 for (std::string line;std::getline(inFile, line);)
 
 for (auto const &test:tests) BOOST_TEST(verify_match(test))
 

Variables

cet::LibraryManager dummy ("noplugin")
 
std::string const pattern_stem = dummy.patternStem()
 
std::string pattern
 
std::regex const pattern2 {R"(.*\[(?:\d+0|\d*[1-9])\])"}
 
std::vector< std::string > const tests {"test[0]", "test[1]", "test[10]"}
 
auto verify_match
 

Macro Definition Documentation

#define BOOST_TEST_MODULE   (regex test)

Definition at line 6 of file regex_t.cc.

Function Documentation

BOOST_TEST_REQUIRE ( static_cast< bool inFile)
for ( std::string line;std::getline(inFile, line);  )

Definition at line 37 of file regex_t.cc.

37  {
38  static std::regex const r(pattern);
39  std::smatch subs;
40  bool result = std::regex_match(line, subs, r);
41  std::cout << line << " match: " << std::boolalpha << result
42  << (result ?
43  (std::string(" (stem ") +
44  subs[1].str().substr(0, subs[1].str().size() - 1) +
45  ", type " + subs[2].str() + ")") :
46  "")
47  << std::endl;
48  BOOST_TEST(result);
49  }
static QCString result
std::string string
Definition: nybbler.cc:12
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
std::string pattern
Definition: regex_t.cc:35
void line(double t, double *p, double &x, double &y, double &z)
static QCString str
QTextStream & endl(QTextStream &s)
for ( auto const &test:tests  )

Variable Documentation

cet::LibraryManager dummy("noplugin")
std::string pattern
Initial value:
=
std::string("lib(") + pattern_stem + ")([A-Za-z0-9]+)\\.so"
std::string string
Definition: nybbler.cc:12
std::string const pattern_stem
Definition: regex_t.cc:33

Definition at line 35 of file regex_t.cc.

std::regex const pattern2 {R"(.*\[(?:\d+0|\d*[1-9])\])"}

Definition at line 57 of file regex_t.cc.

std::string const pattern_stem = dummy.patternStem()

Definition at line 33 of file regex_t.cc.

std::vector< std::string > const tests {"test[0]", "test[1]", "test[10]"}

Definition at line 59 of file regex_t.cc.

auto verify_match
Initial value:
= [&pattern1, &pattern2](std::string const& test) {
return std::regex_match(test, pattern1) ==
std::regex_match(test, pattern2);
}
std::regex const pattern2
Definition: regex_t.cc:57
std::string string
Definition: nybbler.cc:12

Definition at line 61 of file regex_t.cc.