|
|
@@ -24,15 +24,20 @@ struct CaseMatcherTest : public testing::Test {
|
|
|
};
|
|
|
|
|
|
using ::testing::Eq;
|
|
|
+using ::testing::Not;
|
|
|
+
|
|
|
+MATCHER(IsUnmatched, negation ? "was matched" : "was not matched") {
|
|
|
+ return arg.unmatched();
|
|
|
+}
|
|
|
|
|
|
TEST_F(CaseMatcherTest, MatchesCorrectValue) {
|
|
|
match(ex, b) {
|
|
|
with(example{1}, true) {
|
|
|
- EXPECT_FALSE(_matcher_local.unmatched());
|
|
|
+ EXPECT_THAT(_matcher_local, Not(IsUnmatched()));
|
|
|
} nomatch() {
|
|
|
FAIL() << "Unable to match";
|
|
|
}
|
|
|
- EXPECT_FALSE(_matcher_local.unmatched());
|
|
|
+ EXPECT_THAT(_matcher_local, Not(IsUnmatched()));
|
|
|
} else {
|
|
|
FAIL() << "Unable to construct matcher";
|
|
|
}
|
|
|
@@ -43,9 +48,9 @@ TEST_F(CaseMatcherTest, NonMatchingClauseLeavesUnmatched) {
|
|
|
with(example{1}, false) {
|
|
|
FAIL() << "Incorrect match!";
|
|
|
}
|
|
|
- EXPECT_TRUE(_matcher_local.unmatched());
|
|
|
+ EXPECT_THAT(_matcher_local, IsUnmatched());
|
|
|
} else {
|
|
|
- FAIL() << "Unable to construct matcher";
|
|
|
+ FAIL() << "Unable to construct matcher";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -54,13 +59,13 @@ TEST_F(CaseMatcherTest, CanPassMatchingWithSecondClauseListing) {
|
|
|
with(example{1}, false) {
|
|
|
FAIL() << "Incorrect match!";
|
|
|
}
|
|
|
- EXPECT_TRUE(_matcher_local.unmatched());
|
|
|
+ EXPECT_THAT(_matcher_local, IsUnmatched());
|
|
|
with(example{1}, true) {
|
|
|
- EXPECT_FALSE(_matcher_local.unmatched());
|
|
|
+ EXPECT_THAT(_matcher_local, Not(IsUnmatched()));
|
|
|
}
|
|
|
- EXPECT_FALSE(_matcher_local.unmatched());
|
|
|
+ EXPECT_THAT(_matcher_local, Not(IsUnmatched()));
|
|
|
} else {
|
|
|
- FAIL() << "Unable to construct matcher";
|
|
|
+ FAIL() << "Unable to construct matcher";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -70,11 +75,11 @@ TEST_F(CaseMatcherTest, CanMatchWithWildcard) {
|
|
|
FAIL() << "Incorrect match!";
|
|
|
}
|
|
|
with(matcher::any, true) {
|
|
|
- EXPECT_FALSE(_matcher_local.unmatched());
|
|
|
+ EXPECT_THAT(_matcher_local, Not(IsUnmatched()));
|
|
|
}
|
|
|
- EXPECT_FALSE(_matcher_local.unmatched());
|
|
|
+ EXPECT_THAT(_matcher_local, Not(IsUnmatched()));
|
|
|
} else {
|
|
|
- FAIL() << "Unable to construct matcher";
|
|
|
+ FAIL() << "Unable to construct matcher";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -88,7 +93,7 @@ TEST_F(CaseMatcherTest, CanMatchMultipleUnlinkedClauses) {
|
|
|
++hits;
|
|
|
}
|
|
|
} else {
|
|
|
- FAIL() << "Unable to construct matcher";
|
|
|
+ FAIL() << "Unable to construct matcher";
|
|
|
}
|
|
|
EXPECT_THAT(hits, Eq(2));
|
|
|
}
|
|
|
@@ -100,7 +105,7 @@ TEST_F(CaseMatcherTest, CanMatchCompoundList) {
|
|
|
FAIL() << "Unable to match with choice";
|
|
|
}
|
|
|
} else {
|
|
|
- FAIL() << "Unable to construct matcher";
|
|
|
+ FAIL() << "Unable to construct matcher";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -109,8 +114,8 @@ TEST_F(CaseMatcherTest, nomatch_any_of_list_without_self) {
|
|
|
with(matcher::any_of(example{0}, example{0xDEADBEEF}), true) {
|
|
|
FAIL() << "Incorrect match!";
|
|
|
}
|
|
|
- EXPECT_TRUE(_matcher_local.unmatched());
|
|
|
+ EXPECT_THAT(_matcher_local, IsUnmatched());
|
|
|
} else {
|
|
|
- FAIL() << "Unable to construct matcher";
|
|
|
+ FAIL() << "Unable to construct matcher";
|
|
|
}
|
|
|
}
|