MCPcopy Create free account
hub / github.com/Extra-Creativity/Modern-Cpp-Basics / MatchTest

Function MatchTest

08-String & Stream/code/RegexTest.cpp:13–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11static const std::string multiStr = "Test: 127.0.0.1; Test2: 127.0.0.2aaa";
12
13void MatchTest()
14{
15 re2::StringPiece whole1;
16 int a1, b1, c1, d1;
17 if (RE2::FullMatch(singleStr, re2Regex, &whole1, &a1, &b1, &c1, &d1))
18 {
19 std::println("re2 Pass: {} {} {} {} {}", whole1, a1, b1, c1, d1);
20 }
21 else
22 {
23 std::println("Fail");
24 }
25
26 // Notice: structured binding in if clause is not regulated in the standard
27 // So the second whole2 is necessary. MSVC rejects it if it's not provided.
28 if (auto [whole2, a2, b2, c2, d2] = ctre::match<ctreRegex>(singleStr);
29 whole2)
30 {
31 std::println("ctre Pass: {} {} {} {} {}", whole2.to_view(),
32 a2.to_number(), b2.to_number(), c2.to_number(),
33 d2.to_number());
34 }
35 else
36 {
37 std::println("Fail");
38 }
39}
40
41void SearchTest()
42{

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected