From e15c8f3d6a538127a3aa240669c22b916517ef4e Mon Sep 17 00:00:00 2001 From: Eric Paniagua Date: Sat, 5 Sep 2020 09:01:49 -0700 Subject: [PATCH] Make IsEmpty work for SystemControlReport. Signed-off-by: Eric Paniagua --- testing/common/SystemControlReport.cpp | 4 +++- testing/common/matchers.h | 21 --------------------- testing/issue_840/test/simulator_test.cpp | 2 +- 3 files changed, 4 insertions(+), 23 deletions(-) diff --git a/testing/common/SystemControlReport.cpp b/testing/common/SystemControlReport.cpp index 9111259f..e01e4f9d 100644 --- a/testing/common/SystemControlReport.cpp +++ b/testing/common/SystemControlReport.cpp @@ -25,7 +25,9 @@ SystemControlReport::SystemControlReport(const void* data) { const ReportData& report_data = *static_cast(data); memcpy(&report_data_, &report_data, sizeof(report_data_)); - this->push_back(report_data_.key); + if (report_data_.key != 0) { + this->push_back(report_data_.key); + } } uint8_t SystemControlReport::Key() const { diff --git a/testing/common/matchers.h b/testing/common/matchers.h index f521bb35..0ce6ce73 100644 --- a/testing/common/matchers.h +++ b/testing/common/matchers.h @@ -31,27 +31,6 @@ MATCHER_P(Contains, key, negation ? "does not contain" : "contains") { return arg.Key() == key.getKeyCode(); } -class SystemControlReportIsNullMatcher - : public ::testing::MatcherInterface { - public: - bool MatchAndExplain(SystemControlReport report, - ::testing::MatchResultListener* /* ignored */) const override { - return report.Key() == 0; - } - - void DescribeTo(std::ostream* os) const override { - *os << "is empty"; - } - - void DescribeNegationTo(std::ostream* os) const override { - *os << "is not empty"; - } -}; - -::testing::Matcher IsNull() { - return ::testing::MakeMatcher(new SystemControlReportIsNullMatcher); -} - auto Contains(Key key) { return ::testing::Contains(key.getKeyCode()); } } // namespace testing diff --git a/testing/issue_840/test/simulator_test.cpp b/testing/issue_840/test/simulator_test.cpp index b479b5e3..9e06bbb4 100644 --- a/testing/issue_840/test/simulator_test.cpp +++ b/testing/issue_840/test/simulator_test.cpp @@ -59,7 +59,7 @@ TEST_F(Issue840, HasNotRegressed) { state = RunCycle(); ASSERT_EQ(state->SystemControlReports().size(), 1); - EXPECT_THAT(state->SystemControlReports(0), IsNull()); + EXPECT_THAT(state->SystemControlReports(0), IsEmpty()); state = RunCycle();