3636#include " unittest.hpp"
3737#include " utilities/ostream.hpp"
3838
39+ using testing::HasSubstr;
40+
3941class LogConfigurationTest : public LogTestFixture {
4042 protected:
4143 static char _all_decorators[256 ];
@@ -71,26 +73,26 @@ TEST_VM_F(LogConfigurationTest, describe) {
7173 const char * description = ss.as_string ();
7274
7375 // Verify that stdout and stderr are listed by default
74- EXPECT_PRED2 (string_contains_substring, description, StdoutLog.name ());
75- EXPECT_PRED2 (string_contains_substring, description, StderrLog.name ());
76+ EXPECT_THAT ( description, HasSubstr ( StdoutLog.name () ));
77+ EXPECT_THAT ( description, HasSubstr ( StderrLog.name () ));
7678
7779 // Verify that each tag, level and decorator is listed
7880 for (size_t i = 0 ; i < LogTag::Count; i++) {
79- EXPECT_PRED2 (string_contains_substring, description, LogTag::name (static_cast <LogTagType>(i)));
81+ EXPECT_THAT ( description, HasSubstr ( LogTag::name (static_cast <LogTagType>(i) )));
8082 }
8183 for (size_t i = 0 ; i < LogLevel::Count; i++) {
82- EXPECT_PRED2 (string_contains_substring, description, LogLevel::name (static_cast <LogLevelType>(i)));
84+ EXPECT_THAT ( description, HasSubstr ( LogLevel::name (static_cast <LogLevelType>(i) )));
8385 }
8486 for (size_t i = 0 ; i < LogDecorators::Count; i++) {
85- EXPECT_PRED2 (string_contains_substring, description, LogDecorators::name (static_cast <LogDecorators::Decorator>(i)));
87+ EXPECT_THAT ( description, HasSubstr ( LogDecorators::name (static_cast <LogDecorators::Decorator>(i) )));
8688 }
8789
8890 // Verify that the default configuration is printed
8991 char expected_buf[256 ];
9092 int ret = jio_snprintf (expected_buf, sizeof (expected_buf), " =%s" , LogLevel::name (LogLevel::Default));
9193 ASSERT_NE (-1 , ret);
92- EXPECT_PRED2 (string_contains_substring, description, expected_buf);
93- EXPECT_PRED2 (string_contains_substring, description, " #1: stderr all=off" );
94+ EXPECT_THAT ( description, HasSubstr ( expected_buf) );
95+ EXPECT_THAT ( description, HasSubstr ( " #1: stderr all=off" ) );
9496
9597 // Verify default decorators are listed
9698 LogDecorators default_decorators;
@@ -107,7 +109,7 @@ TEST_VM_F(LogConfigurationTest, describe) {
107109 ASSERT_NE (-1 , ret);
108110 }
109111 }
110- EXPECT_PRED2 (string_contains_substring, description, expected_buf);
112+ EXPECT_THAT ( description, HasSubstr ( expected_buf) );
111113
112114 // Add a new output and verify that it gets described after it has been added
113115 const char * what = " all=trace" ;
@@ -493,8 +495,8 @@ TEST_VM_F(LogConfigurationTest, parse_invalid_tagset) {
493495 bool success = LogConfiguration::parse_log_arguments (" stdout" , invalid_tagset, NULL , NULL , &ss);
494496 const char * msg = ss.as_string ();
495497 EXPECT_TRUE (success) << " Should only cause a warning, not an error" ;
496- EXPECT_TRUE ( string_contains_substring ( msg, " No tag set matches selection:" ));
497- EXPECT_TRUE ( string_contains_substring ( msg, invalid_tagset));
498+ EXPECT_THAT ( msg, HasSubstr ( " No tag set matches selection:" ));
499+ EXPECT_THAT ( msg, HasSubstr ( invalid_tagset));
498500}
499501
500502TEST_VM_F (LogConfigurationTest, output_name_normalization) {
@@ -559,7 +561,7 @@ TEST_VM_F(LogConfigurationTest, suggest_similar_selection) {
559561
560562 const char * suggestion = ss.as_string ();
561563 SCOPED_TRACE (suggestion);
562- EXPECT_TRUE ( string_contains_substring (ss. as_string (), " Did you mean any of the following?" ));
564+ EXPECT_THAT (suggestion, HasSubstr ( " Did you mean any of the following?" ));
563565 EXPECT_TRUE (string_contains_substring (suggestion, " logging" ) ||
564566 string_contains_substring (suggestion, " start" ) ||
565567 string_contains_substring (suggestion, " exit" ) ||
0 commit comments