diff options
| author | QMK Bot <hello@qmk.fm> | 2022-02-12 10:29:31 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-12 18:29:31 +0000 |
| commit | 63646e8906e062d1c1de3925cba70c4e3426a855 (patch) | |
| tree | 4e91648b77b838e1125cf86331d7e84bde6d07a9 /tests/test_common | |
| parent | afcdd7079c774dec2aa4b7f2d08adf8b7310919b (diff) | |
Format code according to conventions (#16322)
Diffstat (limited to 'tests/test_common')
| -rw-r--r-- | tests/test_common/keyboard_report_util.cpp | 14 | ||||
| -rw-r--r-- | tests/test_common/matrix.c | 16 | ||||
| -rw-r--r-- | tests/test_common/test_driver.cpp | 20 | ||||
| -rw-r--r-- | tests/test_common/test_fixture.cpp | 4 | ||||
| -rw-r--r-- | tests/test_common/test_logger.cpp | 8 |
5 files changed, 46 insertions, 16 deletions
diff --git a/tests/test_common/keyboard_report_util.cpp b/tests/test_common/keyboard_report_util.cpp index e148c76beb..7908e64f7f 100644 --- a/tests/test_common/keyboard_report_util.cpp +++ b/tests/test_common/keyboard_report_util.cpp | |||
| @@ -36,7 +36,7 @@ std::vector<uint8_t> get_keys(const report_keyboard_t& report) { | |||
| 36 | std::sort(result.begin(), result.end()); | 36 | std::sort(result.begin(), result.end()); |
| 37 | return result; | 37 | return result; |
| 38 | } | 38 | } |
| 39 | } // namespace | 39 | } // namespace |
| 40 | 40 | ||
| 41 | bool operator==(const report_keyboard_t& lhs, const report_keyboard_t& rhs) { | 41 | bool operator==(const report_keyboard_t& lhs, const report_keyboard_t& rhs) { |
| 42 | auto lhskeys = get_keys(lhs); | 42 | auto lhskeys = get_keys(lhs); |
| @@ -72,8 +72,14 @@ KeyboardReportMatcher::KeyboardReportMatcher(const std::vector<uint8_t>& keys) { | |||
| 72 | } | 72 | } |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | bool KeyboardReportMatcher::MatchAndExplain(report_keyboard_t& report, MatchResultListener* listener) const { return m_report == report; } | 75 | bool KeyboardReportMatcher::MatchAndExplain(report_keyboard_t& report, MatchResultListener* listener) const { |
| 76 | return m_report == report; | ||
| 77 | } | ||
| 76 | 78 | ||
| 77 | void KeyboardReportMatcher::DescribeTo(::std::ostream* os) const { *os << "is equal to " << m_report; } | 79 | void KeyboardReportMatcher::DescribeTo(::std::ostream* os) const { |
| 80 | *os << "is equal to " << m_report; | ||
| 81 | } | ||
| 78 | 82 | ||
| 79 | void KeyboardReportMatcher::DescribeNegationTo(::std::ostream* os) const { *os << "is not equal to " << m_report; } | 83 | void KeyboardReportMatcher::DescribeNegationTo(::std::ostream* os) const { |
| 84 | *os << "is not equal to " << m_report; | ||
| 85 | } | ||
diff --git a/tests/test_common/matrix.c b/tests/test_common/matrix.c index 9a92a801c7..7b24d560e3 100644 --- a/tests/test_common/matrix.c +++ b/tests/test_common/matrix.c | |||
| @@ -30,7 +30,9 @@ uint8_t matrix_scan(void) { | |||
| 30 | return 1; | 30 | return 1; |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | matrix_row_t matrix_get_row(uint8_t row) { return matrix[row]; } | 33 | matrix_row_t matrix_get_row(uint8_t row) { |
| 34 | return matrix[row]; | ||
| 35 | } | ||
| 34 | 36 | ||
| 35 | void matrix_print(void) {} | 37 | void matrix_print(void) {} |
| 36 | 38 | ||
| @@ -38,10 +40,16 @@ void matrix_init_kb(void) {} | |||
| 38 | 40 | ||
| 39 | void matrix_scan_kb(void) {} | 41 | void matrix_scan_kb(void) {} |
| 40 | 42 | ||
| 41 | void press_key(uint8_t col, uint8_t row) { matrix[row] |= 1 << col; } | 43 | void press_key(uint8_t col, uint8_t row) { |
| 44 | matrix[row] |= 1 << col; | ||
| 45 | } | ||
| 42 | 46 | ||
| 43 | void release_key(uint8_t col, uint8_t row) { matrix[row] &= ~(1 << col); } | 47 | void release_key(uint8_t col, uint8_t row) { |
| 48 | matrix[row] &= ~(1 << col); | ||
| 49 | } | ||
| 44 | 50 | ||
| 45 | void clear_all_keys(void) { memset(matrix, 0, sizeof(matrix)); } | 51 | void clear_all_keys(void) { |
| 52 | memset(matrix, 0, sizeof(matrix)); | ||
| 53 | } | ||
| 46 | 54 | ||
| 47 | void led_set(uint8_t usb_led) {} | 55 | void led_set(uint8_t usb_led) {} |
diff --git a/tests/test_common/test_driver.cpp b/tests/test_common/test_driver.cpp index 2fa2b6a2e7..68f1dfd17d 100644 --- a/tests/test_common/test_driver.cpp +++ b/tests/test_common/test_driver.cpp | |||
| @@ -23,17 +23,27 @@ TestDriver::TestDriver() : m_driver{&TestDriver::keyboard_leds, &TestDriver::sen | |||
| 23 | m_this = this; | 23 | m_this = this; |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | TestDriver::~TestDriver() { m_this = nullptr; } | 26 | TestDriver::~TestDriver() { |
| 27 | m_this = nullptr; | ||
| 28 | } | ||
| 27 | 29 | ||
| 28 | uint8_t TestDriver::keyboard_leds(void) { return m_this->m_leds; } | 30 | uint8_t TestDriver::keyboard_leds(void) { |
| 31 | return m_this->m_leds; | ||
| 32 | } | ||
| 29 | 33 | ||
| 30 | void TestDriver::send_keyboard(report_keyboard_t* report) { | 34 | void TestDriver::send_keyboard(report_keyboard_t* report) { |
| 31 | test_logger.trace() << *report; | 35 | test_logger.trace() << *report; |
| 32 | m_this->send_keyboard_mock(*report); | 36 | m_this->send_keyboard_mock(*report); |
| 33 | } | 37 | } |
| 34 | 38 | ||
| 35 | void TestDriver::send_mouse(report_mouse_t* report) { m_this->send_mouse_mock(*report); } | 39 | void TestDriver::send_mouse(report_mouse_t* report) { |
| 40 | m_this->send_mouse_mock(*report); | ||
| 41 | } | ||
| 36 | 42 | ||
| 37 | void TestDriver::send_system(uint16_t data) { m_this->send_system_mock(data); } | 43 | void TestDriver::send_system(uint16_t data) { |
| 44 | m_this->send_system_mock(data); | ||
| 45 | } | ||
| 38 | 46 | ||
| 39 | void TestDriver::send_consumer(uint16_t data) { m_this->send_consumer(data); } | 47 | void TestDriver::send_consumer(uint16_t data) { |
| 48 | m_this->send_consumer(data); | ||
| 49 | } | ||
diff --git a/tests/test_common/test_fixture.cpp b/tests/test_common/test_fixture.cpp index 91bf3e779e..c98a679554 100644 --- a/tests/test_common/test_fixture.cpp +++ b/tests/test_common/test_fixture.cpp | |||
| @@ -55,7 +55,9 @@ void TestFixture::SetUpTestCase() { | |||
| 55 | 55 | ||
| 56 | void TestFixture::TearDownTestCase() {} | 56 | void TestFixture::TearDownTestCase() {} |
| 57 | 57 | ||
| 58 | TestFixture::TestFixture() { m_this = this; } | 58 | TestFixture::TestFixture() { |
| 59 | m_this = this; | ||
| 60 | } | ||
| 59 | 61 | ||
| 60 | TestFixture::~TestFixture() { | 62 | TestFixture::~TestFixture() { |
| 61 | test_logger.info() << "TestFixture clean-up start." << std::endl; | 63 | test_logger.info() << "TestFixture clean-up start." << std::endl; |
diff --git a/tests/test_common/test_logger.cpp b/tests/test_common/test_logger.cpp index 959fdde5ec..efc7719d13 100644 --- a/tests/test_common/test_logger.cpp +++ b/tests/test_common/test_logger.cpp | |||
| @@ -34,6 +34,10 @@ TestLogger& TestLogger::error() { | |||
| 34 | return *this; | 34 | return *this; |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | void TestLogger::reset() { this->m_log.str(""); }; | 37 | void TestLogger::reset() { |
| 38 | this->m_log.str(""); | ||
| 39 | }; | ||
| 38 | 40 | ||
| 39 | void TestLogger::print_log() { std::cerr << this->m_log.str(); } | 41 | void TestLogger::print_log() { |
| 42 | std::cerr << this->m_log.str(); | ||
| 43 | } | ||
