当前位置: 首页>>代码示例>>C++>>正文


C++ testing::MatchesRegex方法代码示例

本文整理汇总了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.*"));
}
开发者ID:Gitborter,项目名称:cryfs,代码行数:7,代码来源:LoggingTest.cpp

示例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.*"
    ));
  }
}
开发者ID:cryfs,项目名称:cryfs,代码行数:10,代码来源:assert_release_test.cpp

示例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);
}
开发者ID:AiprNick,项目名称:memento,代码行数:18,代码来源:httpdigestauthenticate_test.cpp

示例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();
}
开发者ID:ClearwaterCore,项目名称:sprout,代码行数:19,代码来源:session_expires_helper_test.cpp

示例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"));
//.........这里部分代码省略.........
开发者ID:gangbanlau,项目名称:sprout,代码行数:101,代码来源:registrar_test.cpp

示例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.*"));
}
开发者ID:Gitborter,项目名称:cryfs,代码行数:6,代码来源:LoggingTest.cpp

示例7: captureStderr

TEST_F(LoggingTest, DefaultLoggerIsStderr) {
    string output = captureStderr([]{
        LOG(INFO) << "My log message";
    });
    EXPECT_THAT(output, MatchesRegex(".*\\[Log\\].*\\[info\\].*My log message.*"));
}
开发者ID:Gitborter,项目名称:cryfs,代码行数:6,代码来源:LoggingTest.cpp


注:本文中的testing::MatchesRegex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。