aboutsummaryrefslogtreecommitdiff
path: root/tests/test_common/keyboard_report_util.cpp
diff options
context:
space:
mode:
authorskullY <skullydazed@gmail.com>2019-08-30 11:19:03 -0700
committerskullydazed <skullydazed@users.noreply.github.com>2019-08-30 15:01:52 -0700
commitb624f32f944acdc59dcb130674c09090c5c404cb (patch)
treebc13adbba137d122d9a2c2fb2fafcbb08ac10e25 /tests/test_common/keyboard_report_util.cpp
parent61af76a10d00aba185b8338604171de490a13e3b (diff)
downloadqmk_firmware-b624f32f944acdc59dcb130674c09090c5c404cb.tar.gz
qmk_firmware-b624f32f944acdc59dcb130674c09090c5c404cb.zip
clang-format changes
Diffstat (limited to 'tests/test_common/keyboard_report_util.cpp')
-rw-r--r--tests/test_common/keyboard_report_util.cpp62
1 files changed, 27 insertions, 35 deletions
diff --git a/tests/test_common/keyboard_report_util.cpp b/tests/test_common/keyboard_report_util.cpp
index bf728b9a2..245072c0e 100644
--- a/tests/test_common/keyboard_report_util.cpp
+++ b/tests/test_common/keyboard_report_util.cpp
@@ -14,30 +14,29 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */ 15 */
16 16
17 #include "keyboard_report_util.hpp" 17#include "keyboard_report_util.hpp"
18 #include <vector> 18#include <vector>
19 #include <algorithm> 19#include <algorithm>
20 using namespace testing; 20using namespace testing;
21 21
22 namespace 22namespace {
23 { 23std::vector<uint8_t> get_keys(const report_keyboard_t& report) {
24 std::vector<uint8_t> get_keys(const report_keyboard_t& report) { 24 std::vector<uint8_t> result;
25 std::vector<uint8_t> result; 25#if defined(NKRO_ENABLE)
26 #if defined(NKRO_ENABLE) 26# error NKRO support not implemented yet
27 #error NKRO support not implemented yet 27#elif defined(USB_6KRO_ENABLE)
28 #elif defined(USB_6KRO_ENABLE) 28# error 6KRO support not implemented yet
29 #error 6KRO support not implemented yet 29#else
30 #else 30 for (size_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) {
31 for(size_t i=0; i<KEYBOARD_REPORT_KEYS; i++) { 31 if (report.keys[i]) {
32 if (report.keys[i]) { 32 result.emplace_back(report.keys[i]);
33 result.emplace_back(report.keys[i]);
34 }
35 } 33 }
36 #endif 34 }
37 std::sort(result.begin(), result.end()); 35#endif
38 return result; 36 std::sort(result.begin(), result.end());
39 } 37 return result;
40 } 38}
39} // namespace
41 40
42bool operator==(const report_keyboard_t& lhs, const report_keyboard_t& rhs) { 41bool operator==(const report_keyboard_t& lhs, const report_keyboard_t& rhs) {
43 auto lhskeys = get_keys(lhs); 42 auto lhskeys = get_keys(lhs);
@@ -50,7 +49,7 @@ std::ostream& operator<<(std::ostream& stream, const report_keyboard_t& value) {
50 stream << "Mods: " << (uint32_t)value.mods << std::endl; 49 stream << "Mods: " << (uint32_t)value.mods << std::endl;
51 stream << "Keys: "; 50 stream << "Keys: ";
52 // TODO: This should probably print friendly names for the keys 51 // TODO: This should probably print friendly names for the keys
53 for (uint32_t k: get_keys(value)) { 52 for (uint32_t k : get_keys(value)) {
54 stream << k << " "; 53 stream << k << " ";
55 } 54 }
56 stream << std::endl; 55 stream << std::endl;
@@ -59,24 +58,17 @@ std::ostream& operator<<(std::ostream& stream, const report_keyboard_t& value) {
59 58
60KeyboardReportMatcher::KeyboardReportMatcher(const std::vector<uint8_t>& keys) { 59KeyboardReportMatcher::KeyboardReportMatcher(const std::vector<uint8_t>& keys) {
61 memset(m_report.raw, 0, sizeof(m_report.raw)); 60 memset(m_report.raw, 0, sizeof(m_report.raw));
62 for (auto k: keys) { 61 for (auto k : keys) {
63 if (IS_MOD(k)) { 62 if (IS_MOD(k)) {
64 m_report.mods |= MOD_BIT(k); 63 m_report.mods |= MOD_BIT(k);
65 } 64 } else {
66 else {
67 add_key_to_report(&m_report, k); 65 add_key_to_report(&m_report, k);
68 } 66 }
69 } 67 }
70} 68}
71 69
72bool KeyboardReportMatcher::MatchAndExplain(report_keyboard_t& report, MatchResultListener* listener) const { 70bool KeyboardReportMatcher::MatchAndExplain(report_keyboard_t& report, MatchResultListener* listener) const { return m_report == report; }
73 return m_report == report;
74}
75 71
76void KeyboardReportMatcher::DescribeTo(::std::ostream* os) const { 72void KeyboardReportMatcher::DescribeTo(::std::ostream* os) const { *os << "is equal to " << m_report; }
77 *os << "is equal to " << m_report;
78}
79 73
80void KeyboardReportMatcher::DescribeNegationTo(::std::ostream* os) const { 74void KeyboardReportMatcher::DescribeNegationTo(::std::ostream* os) const { *os << "is not equal to " << m_report; } \ No newline at end of file
81 *os << "is not equal to " << m_report;
82} \ No newline at end of file