From c2b13bd77b71ea73db12a6cda64871565036a6dc Mon Sep 17 00:00:00 2001 From: Stefan Kerkmann Date: Sun, 18 Dec 2022 21:55:14 +0100 Subject: Introduce VERIFY_AND_CLEAR shorthand (#19370) Which is just a syntactic sugar for testing::Mock::VerifyAndClearExpectations to reduce the visual clutter in unit-tests. --- tests/test_common/test_driver.hpp | 6 ++++++ tests/test_common/test_fixture.cpp | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'tests/test_common') diff --git a/tests/test_common/test_driver.hpp b/tests/test_common/test_driver.hpp index 982aec6c83..8d09e44840 100644 --- a/tests/test_common/test_driver.hpp +++ b/tests/test_common/test_driver.hpp @@ -98,6 +98,12 @@ class TestDriver { */ #define EXPECT_NO_REPORT(driver) EXPECT_ANY_REPORT(driver).Times(0) +/** + * @brief Verify and clear all gmock expectations that have been setup until + * this point. + */ +#define VERIFY_AND_CLEAR(driver) testing::Mock::VerifyAndClearExpectations(&driver) + namespace internal { void expect_unicode_code_point(TestDriver& driver, uint32_t code_point); } // namespace internal diff --git a/tests/test_common/test_fixture.cpp b/tests/test_common/test_fixture.cpp index 5dc5db1848..76daa625ad 100644 --- a/tests/test_common/test_fixture.cpp +++ b/tests/test_common/test_fixture.cpp @@ -82,12 +82,12 @@ TestFixture::~TestFixture() { #endif idle_for(TAPPING_TERM * 10); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); /* Verify that the matrix really is cleared */ EXPECT_NO_REPORT(driver); idle_for(TAPPING_TERM * 10); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); m_this = nullptr; test_logger.info() << "test fixture clean-up end." << std::endl; -- cgit v1.2.3