Skip to content

Commit b85fa57

Browse files
committed
Rename IsNan as MyIsNan since gtest ≥v1.12 now includes it
1 parent 87730a2 commit b85fa57

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

gtest/gtest-matchers--unittest.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,20 @@
77

88
// more details in
99
// https://github.com/google/googletest/blob/master/docs/gmock_cheat_sheet.md#defining-matchers
10-
MATCHER(IsEven, "") { return (arg % 2) == 0; }
11-
MATCHER(IsNan, "NaN value") { return ::std::isnan(arg); }
12-
MATCHER_P(IsDivisibleBy, n, "") {
13-
*result_listener << "where the remainder is " << (arg % n);
14-
return (arg % n) == 0;
10+
MATCHER(MyIsEven, "") { return (arg % 2) == 0; }
11+
// IsNan is now alailable in gtest v1.12
12+
MATCHER(MyIsNan, "NaN value") { return ::std::isnan(arg); }
13+
14+
MATCHER_P(MyIsDivisibleBy, n, "") {
15+
*result_listener << "where the remainder is " << (arg % n);
16+
return (arg % n) == 0;
1517
}
1618

1719
TEST(SuitName, TestCaseName) {
18-
using ::testing::Not;
19-
using namespace ::testing;
20+
using ::testing::Not;
21+
using namespace ::testing;
2022

21-
ASSERT_THAT(2, IsEven());
22-
ASSERT_THAT(2.0, Not(IsNan()));
23-
ASSERT_THAT(12, IsDivisibleBy(4));
23+
ASSERT_THAT(2, MyIsEven());
24+
ASSERT_THAT(2.0, Not(MyIsNan()));
25+
ASSERT_THAT(12, MyIsDivisibleBy(4));
2426
}

0 commit comments

Comments
 (0)