本文整理汇总了C++中testing::MatchesRegex方法的典型用法代码示例。如果您正苦于以下问题:C++ testing::MatchesRegex方法的具体用法?C++ testing::MatchesRegex怎么用?C++ testing::MatchesRegex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类testing
的用法示例。
在下文中一共展示了testing::MatchesRegex方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setLogger
TEST_F(LoggingTest, SetLogger_NewLoggerIsUsed) {
setLogger(spdlog::stderr_logger_mt("MyTestLog2"));
string output = captureStderr([]{
LOG(INFO) << "My log message";
});
EXPECT_THAT(output, MatchesRegex(".*\\[MyTestLog2\\].*\\[info\\].*My log message.*"));
}
示例2: ASSERT
TEST(AssertTest_ReleaseBuild, AssertMessage) {
try {
ASSERT(2==5, "my message");
FAIL();
} catch (const cpputils::AssertFailed &e) {
EXPECT_THAT(e.what(), MatchesRegex(
"Assertion \\[2==5\\] failed in .*/assert_release_test.cpp:25: my message.*"
));
}
}
示例3: MatchesRegex
TEST_F(HTTPDigestAuthenticateTest, RequestStoreDigest)
{
std::vector<std::string> test;
test.push_back("digest_1");
test.push_back("realm");
_hc->set_result("/impi/1231231231%40home.domain/av?impu=sip%3A1231231231%40home.domain", test);
// set the _impu/_impi
_auth_mod->set_members("sip:[email protected]", "GET", "[email protected]", 0);
// Request the digest.
std::string www_auth_header;
long rc = _auth_mod->request_digest_and_store(www_auth_header, false, _response);
EXPECT_THAT(www_auth_header,
MatchesRegex("Digest realm=\"home\\.domain\",qop=\"auth\",nonce=\".*\",opaque=\".*\""));
ASSERT_EQ(rc, 401);
}
示例4: MatchesRegex
TEST_F(SessionExpiresHelperTest, ClientSupportsTimerSEModified)
{
Message msg1;
msg1._uac_supports_timer = true;
msg1._se = "Session-Expires: 800";
do_request_flow(&msg1);
EXPECT_EQ(get_headers(current_txdata()->msg, "Session-Expires"),
"Session-Expires: 600");
do_response_flow();
EXPECT_EQ(get_headers(current_txdata()->msg, "Session-Expires"),
"Session-Expires: 600;refresher=uac");
EXPECT_THAT(get_headers(current_txdata()->msg, "Require"),
MatchesRegex("Require:.*[ ,]timer($|[ ,])"));
free_txdata();
}
示例5: MatchesRegex
TEST_F(RegistrarTest, MultipleRegistrations)
{
// First registration OK.
Message msg;
inject_msg(msg.get());
ASSERT_EQ(1, txdata_count());
pjsip_msg* out = current_txdata()->msg;
EXPECT_EQ(200, out->line.status.code);
free_txdata();
// Second registration also OK. Bindings are ordered by binding ID.
Message msg0;
msg = msg0;
msg._contact = "sip:[email protected]:5061;transport=tcp;ob";
msg._contact_instance = ";+sip.instance=\"<urn:uuid:00000000-0000-0000-0000-a55444444440>\"";
msg._path = "Path: sip:[email protected]119.compute-1.amazonaws.com:5060;lr;ob";
inject_msg(msg.get());
ASSERT_EQ(1, txdata_count());
out = current_txdata()->msg;
EXPECT_EQ(200, out->line.status.code);
EXPECT_EQ("OK", str_pj(out->line.status.reason));
EXPECT_EQ("Supported: outbound", get_headers(out, "Supported"));
// Expires timer for first contact may have ticked down, so give it some leeway.
EXPECT_THAT(get_headers(out, "Contact"),
MatchesRegex("Contact: sip:[email protected]:5061;transport=tcp;ob;expires=(300|[1-2][0-9][0-9]|[1-9][0-9]|[1-9]);\\+sip.ice;reg-id=1;\\+sip.instance=\"<urn:uuid:00000000-0000-0000-0000-a55444444440>\"\r\n"
"Contact: sip:[email protected]:5061;transport=tcp;ob;expires=(300|[1-2][0-9][0-9]|[1-9][0-9]|[1-9]);\\+sip.ice;reg-id=1;\\+sip.instance=\"<urn:uuid:00000000-0000-0000-0000-b665231f1213>\""));
// get_headers(out, "Contact"));
EXPECT_EQ("Require: outbound", get_headers(out, "Require")); // because we have path
EXPECT_EQ(msg._path, get_headers(out, "Path"));
EXPECT_EQ("P-Associated-URI: sip:[email protected]", get_headers(out, "P-Associated-URI"));
EXPECT_EQ("Service-Route: <sip:all.the.sprout.nodes:5058;transport=TCP;lr;orig>", get_headers(out, "Service-Route"));
free_txdata();
// Reregistration of first binding is OK but doesn't add a new one.
msg = msg0;
inject_msg(msg.get());
ASSERT_EQ(1, txdata_count());
out = current_txdata()->msg;
EXPECT_EQ(200, out->line.status.code);
EXPECT_EQ("OK", str_pj(out->line.status.reason));
EXPECT_EQ("Supported: outbound", get_headers(out, "Supported"));
EXPECT_THAT(get_headers(out, "Contact"),
MatchesRegex("Contact: sip:[email protected]:5061;transport=tcp;ob;expires=(300|[1-2][0-9][0-9]|[1-9][0-9]|[1-9]);\\+sip.ice;reg-id=1;\\+sip.instance=\"<urn:uuid:00000000-0000-0000-0000-a55444444440>\"\r\n"
"Contact: sip:[email protected]:5061;transport=tcp;ob;expires=(300|[1-2][0-9][0-9]|[1-9][0-9]|[1-9]);\\+sip.ice;reg-id=1;\\+sip.instance=\"<urn:uuid:00000000-0000-0000-0000-b665231f1213>\""));
EXPECT_EQ("Require: outbound", get_headers(out, "Require")); // because we have path
EXPECT_EQ(msg._path, get_headers(out, "Path"));
EXPECT_EQ("P-Associated-URI: sip:[email protected]", get_headers(out, "P-Associated-URI"));
EXPECT_EQ("Service-Route: <sip:all.the.sprout.nodes:5058;transport=TCP;lr;orig>", get_headers(out, "Service-Route"));
free_txdata();
// Registering the first binding again but without the binding ID counts as a separate binding (named by the contact itself). Bindings are ordered by binding ID.
msg = msg0;
msg._contact_instance = "";
inject_msg(msg.get());
ASSERT_EQ(1, txdata_count());
out = current_txdata()->msg;
EXPECT_EQ(200, out->line.status.code);
EXPECT_EQ("OK", str_pj(out->line.status.reason));
EXPECT_EQ("Supported: outbound", get_headers(out, "Supported"));
EXPECT_THAT(get_headers(out, "Contact"),
MatchesRegex("Contact: sip:[email protected]:5061;transport=tcp;ob;expires=(300|[1-2][0-9][0-9]|[1-9][0-9]|[1-9]);\\+sip.ice;reg-id=1;\\+sip.instance=\"<urn:uuid:00000000-0000-0000-0000-a55444444440>\"\r\n"
"Contact: sip:[email protected]:5061;transport=tcp;ob;expires=(300|[1-2][0-9][0-9]|[1-9][0-9]|[1-9]);\\+sip.ice;reg-id=1;\\+sip.instance=\"<urn:uuid:00000000-0000-0000-0000-b665231f1213>\"\r\n"
"Contact: sip:[email protected]:5061;transport=tcp;ob;expires=(300|[1-2][0-9][0-9]|[1-9][0-9]|[1-9]);\\+sip.ice;reg-id=1"));
EXPECT_EQ("Require: outbound", get_headers(out, "Require")); // because we have path
EXPECT_EQ(msg._path, get_headers(out, "Path"));
EXPECT_EQ("P-Associated-URI: sip:[email protected]", get_headers(out, "P-Associated-URI"));
EXPECT_EQ("Service-Route: <sip:all.the.sprout.nodes:5058;transport=TCP;lr;orig>", get_headers(out, "Service-Route"));
free_txdata();
// Reregistering that yields no change.
inject_msg(msg.get());
ASSERT_EQ(1, txdata_count());
out = current_txdata()->msg;
EXPECT_EQ(200, out->line.status.code);
EXPECT_EQ("OK", str_pj(out->line.status.reason));
EXPECT_EQ("Supported: outbound", get_headers(out, "Supported"));
EXPECT_THAT(get_headers(out, "Contact"),
MatchesRegex("Contact: sip:[email protected]:5061;transport=tcp;ob;expires=(300|[1-2][0-9][0-9]|[1-9][0-9]|[1-9]);\\+sip.ice;reg-id=1;\\+sip.instance=\"<urn:uuid:00000000-0000-0000-0000-a55444444440>\"\r\n"
"Contact: sip:[email protected]:5061;transport=tcp;ob;expires=(300|[1-2][0-9][0-9]|[1-9][0-9]|[1-9]);\\+sip.ice;reg-id=1;\\+sip.instance=\"<urn:uuid:00000000-0000-0000-0000-b665231f1213>\"\r\n"
"Contact: sip:[email protected]:5061;transport=tcp;ob;expires=(300|[1-2][0-9][0-9]|[1-9][0-9]|[1-9]);\\+sip.ice;reg-id=1"));
EXPECT_EQ("Require: outbound", get_headers(out, "Require")); // because we have path
EXPECT_EQ(msg._path, get_headers(out, "Path"));
EXPECT_EQ("P-Associated-URI: sip:[email protected]", get_headers(out, "P-Associated-URI"));
EXPECT_EQ("Service-Route: <sip:all.the.sprout.nodes:5058;transport=TCP;lr;orig>", get_headers(out, "Service-Route"));
free_txdata();
// Registration of star clears all bindings.
msg = msg0;
msg._contact = "*";
msg._contact_instance = "";
msg._contact_params = "";
inject_msg(msg.get());
ASSERT_EQ(1, txdata_count());
out = current_txdata()->msg;
EXPECT_EQ(200, out->line.status.code);
EXPECT_EQ("OK", str_pj(out->line.status.reason));
EXPECT_EQ("Supported: outbound", get_headers(out, "Supported"));
EXPECT_EQ("", get_headers(out, "Contact"));
EXPECT_EQ("", get_headers(out, "Require")); // even though we have path, we have no bindings
EXPECT_EQ(msg._path, get_headers(out, "Path"));
//.........这里部分代码省略.........
示例6: setLevel
TEST_F(LoggingTest, DebugLog) {
setLevel(DEBUG);
setLogger(mockLogger.get());
LOG(DEBUG) << "My log message";
EXPECT_THAT(mockLogger.capturedLog(), MatchesRegex(".*\\[MockLogger\\].*\\[debug\\].*My log message.*"));
}
示例7: captureStderr
TEST_F(LoggingTest, DefaultLoggerIsStderr) {
string output = captureStderr([]{
LOG(INFO) << "My log message";
});
EXPECT_THAT(output, MatchesRegex(".*\\[Log\\].*\\[info\\].*My log message.*"));
}