36
36
#include " unittest.hpp"
37
37
#include " utilities/ostream.hpp"
38
38
39
+ using testing::HasSubstr;
40
+
39
41
class LogConfigurationTest : public LogTestFixture {
40
42
protected:
41
43
static char _all_decorators[256 ];
@@ -71,26 +73,26 @@ TEST_VM_F(LogConfigurationTest, describe) {
71
73
const char * description = ss.as_string ();
72
74
73
75
// 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 () ));
76
78
77
79
// Verify that each tag, level and decorator is listed
78
80
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) )));
80
82
}
81
83
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) )));
83
85
}
84
86
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) )));
86
88
}
87
89
88
90
// Verify that the default configuration is printed
89
91
char expected_buf[256 ];
90
92
int ret = jio_snprintf (expected_buf, sizeof (expected_buf), " =%s" , LogLevel::name (LogLevel::Default));
91
93
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" ) );
94
96
95
97
// Verify default decorators are listed
96
98
LogDecorators default_decorators;
@@ -107,7 +109,7 @@ TEST_VM_F(LogConfigurationTest, describe) {
107
109
ASSERT_NE (-1 , ret);
108
110
}
109
111
}
110
- EXPECT_PRED2 (string_contains_substring, description, expected_buf);
112
+ EXPECT_THAT ( description, HasSubstr ( expected_buf) );
111
113
112
114
// Add a new output and verify that it gets described after it has been added
113
115
const char * what = " all=trace" ;
@@ -493,8 +495,8 @@ TEST_VM_F(LogConfigurationTest, parse_invalid_tagset) {
493
495
bool success = LogConfiguration::parse_log_arguments (" stdout" , invalid_tagset, NULL , NULL , &ss);
494
496
const char * msg = ss.as_string ();
495
497
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));
498
500
}
499
501
500
502
TEST_VM_F (LogConfigurationTest, output_name_normalization) {
@@ -559,7 +561,7 @@ TEST_VM_F(LogConfigurationTest, suggest_similar_selection) {
559
561
560
562
const char * suggestion = ss.as_string ();
561
563
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?" ));
563
565
EXPECT_TRUE (string_contains_substring (suggestion, " logging" ) ||
564
566
string_contains_substring (suggestion, " start" ) ||
565
567
string_contains_substring (suggestion, " exit" ) ||
0 commit comments