summaryrefslogtreecommitdiff
path: root/tests/test_common
diff options
context:
space:
mode:
authorQMK Bot <hello@qmk.fm>2022-02-12 10:29:31 -0800
committerGitHub <noreply@github.com>2022-02-12 18:29:31 +0000
commit63646e8906e062d1c1de3925cba70c4e3426a855 (patch)
tree4e91648b77b838e1125cf86331d7e84bde6d07a9 /tests/test_common
parentafcdd7079c774dec2aa4b7f2d08adf8b7310919b (diff)
Format code according to conventions (#16322)
Diffstat (limited to 'tests/test_common')
-rw-r--r--tests/test_common/keyboard_report_util.cpp14
-rw-r--r--tests/test_common/matrix.c16
-rw-r--r--tests/test_common/test_driver.cpp20
-rw-r--r--tests/test_common/test_fixture.cpp4
-rw-r--r--tests/test_common/test_logger.cpp8
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
41bool operator==(const report_keyboard_t& lhs, const report_keyboard_t& rhs) { 41bool 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
75bool KeyboardReportMatcher::MatchAndExplain(report_keyboard_t& report, MatchResultListener* listener) const { return m_report == report; } 75bool KeyboardReportMatcher::MatchAndExplain(report_keyboard_t& report, MatchResultListener* listener) const {
76 return m_report == report;
77}
76 78
77void KeyboardReportMatcher::DescribeTo(::std::ostream* os) const { *os << "is equal to " << m_report; } 79void KeyboardReportMatcher::DescribeTo(::std::ostream* os) const {
80 *os << "is equal to " << m_report;
81}
78 82
79void KeyboardReportMatcher::DescribeNegationTo(::std::ostream* os) const { *os << "is not equal to " << m_report; } 83void 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
33matrix_row_t matrix_get_row(uint8_t row) { return matrix[row]; } 33matrix_row_t matrix_get_row(uint8_t row) {
34 return matrix[row];
35}
34 36
35void matrix_print(void) {} 37void matrix_print(void) {}
36 38
@@ -38,10 +40,16 @@ void matrix_init_kb(void) {}
38 40
39void matrix_scan_kb(void) {} 41void matrix_scan_kb(void) {}
40 42
41void press_key(uint8_t col, uint8_t row) { matrix[row] |= 1 << col; } 43void press_key(uint8_t col, uint8_t row) {
44 matrix[row] |= 1 << col;
45}
42 46
43void release_key(uint8_t col, uint8_t row) { matrix[row] &= ~(1 << col); } 47void release_key(uint8_t col, uint8_t row) {
48 matrix[row] &= ~(1 << col);
49}
44 50
45void clear_all_keys(void) { memset(matrix, 0, sizeof(matrix)); } 51void clear_all_keys(void) {
52 memset(matrix, 0, sizeof(matrix));
53}
46 54
47void led_set(uint8_t usb_led) {} 55void 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
26TestDriver::~TestDriver() { m_this = nullptr; } 26TestDriver::~TestDriver() {
27 m_this = nullptr;
28}
27 29
28uint8_t TestDriver::keyboard_leds(void) { return m_this->m_leds; } 30uint8_t TestDriver::keyboard_leds(void) {
31 return m_this->m_leds;
32}
29 33
30void TestDriver::send_keyboard(report_keyboard_t* report) { 34void 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
35void TestDriver::send_mouse(report_mouse_t* report) { m_this->send_mouse_mock(*report); } 39void TestDriver::send_mouse(report_mouse_t* report) {
40 m_this->send_mouse_mock(*report);
41}
36 42
37void TestDriver::send_system(uint16_t data) { m_this->send_system_mock(data); } 43void TestDriver::send_system(uint16_t data) {
44 m_this->send_system_mock(data);
45}
38 46
39void TestDriver::send_consumer(uint16_t data) { m_this->send_consumer(data); } 47void 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
56void TestFixture::TearDownTestCase() {} 56void TestFixture::TearDownTestCase() {}
57 57
58TestFixture::TestFixture() { m_this = this; } 58TestFixture::TestFixture() {
59 m_this = this;
60}
59 61
60TestFixture::~TestFixture() { 62TestFixture::~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
37void TestLogger::reset() { this->m_log.str(""); }; 37void TestLogger::reset() {
38 this->m_log.str("");
39};
38 40
39void TestLogger::print_log() { std::cerr << this->m_log.str(); } 41void TestLogger::print_log() {
42 std::cerr << this->m_log.str();
43}