Make IsEmpty work for SystemControlReport.

Signed-off-by: Eric Paniagua <epaniagua@google.com>
pull/898/head
Eric Paniagua 4 years ago
parent 0cab1494b5
commit e15c8f3d6a

@ -25,7 +25,9 @@ SystemControlReport::SystemControlReport(const void* data) {
const ReportData& report_data = const ReportData& report_data =
*static_cast<const ReportData*>(data); *static_cast<const ReportData*>(data);
memcpy(&report_data_, &report_data, sizeof(report_data_)); memcpy(&report_data_, &report_data, sizeof(report_data_));
if (report_data_.key != 0) {
this->push_back(report_data_.key); this->push_back(report_data_.key);
}
} }
uint8_t SystemControlReport::Key() const { uint8_t SystemControlReport::Key() const {

@ -31,27 +31,6 @@ MATCHER_P(Contains, key, negation ? "does not contain" : "contains") {
return arg.Key() == key.getKeyCode(); return arg.Key() == key.getKeyCode();
} }
class SystemControlReportIsNullMatcher
: public ::testing::MatcherInterface<SystemControlReport> {
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<SystemControlReport> IsNull() {
return ::testing::MakeMatcher(new SystemControlReportIsNullMatcher);
}
auto Contains(Key key) { return ::testing::Contains(key.getKeyCode()); } auto Contains(Key key) { return ::testing::Contains(key.getKeyCode()); }
} // namespace testing } // namespace testing

@ -59,7 +59,7 @@ TEST_F(Issue840, HasNotRegressed) {
state = RunCycle(); state = RunCycle();
ASSERT_EQ(state->SystemControlReports().size(), 1); ASSERT_EQ(state->SystemControlReports().size(), 1);
EXPECT_THAT(state->SystemControlReports(0), IsNull()); EXPECT_THAT(state->SystemControlReports(0), IsEmpty());
state = RunCycle(); state = RunCycle();

Loading…
Cancel
Save