Skip to content

Commit a409eda

Browse files
authored
Test AliceO2 regex match (#93)
1 parent 01084b0 commit a409eda

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ set(TEST_SRCS
178178
test/testProcessMonitor.cxx
179179
test/testInfluxDb.cxx
180180
test/testNoop.cxx
181+
test/testRegexMatch.cxx
181182
)
182183

183184
if(ApMon_FOUND)

test/testRegexMatch.cxx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include <iostream>
2+
#include <regex>
3+
#include <string>
4+
#include <vector>
5+
6+
#define BOOST_TEST_MODULE Test Monitoring RegexMatch
7+
#define BOOST_TEST_DYN_LINK
8+
#include <boost/test/unit_test.hpp>
9+
10+
namespace o2 {
11+
namespace monitoring {
12+
namespace Test {
13+
14+
BOOST_AUTO_TEST_CASE(retrieveOtherParams)
15+
{
16+
static std::regex metricsRE(R"regex(\[METRIC\] ([a-zA-Z0-9/_-]+),(0|1|2|4) ([0-9.a-zA-Z_/" <>()<$:]+) ([0-9]+))regex", std::regex::optimize);
17+
18+
std::vector<std::string> metrics = {
19+
"[METRIC] bkey,0 12 1789372894 hostname=test.cern.ch",
20+
"[METRIC] bkey,0 \"Sample string\" 1789372894 hostname=test.cern.ch",
21+
"[METRIC] bkey,0 \"<matcher query: (and origin:TST (and description:A1 (and subSpec:77 (just startTime:$0 ))))>\" 1789372894 hostname=test.cern.ch"
22+
};
23+
24+
std::smatch match;
25+
for (const auto& metric : metrics) {
26+
BOOST_CHECK(std::regex_search(metric, match, metricsRE));
27+
}
28+
}
29+
30+
} // namespace Test
31+
} // namespace monitoring
32+
} // namespace o2

0 commit comments

Comments
 (0)