From 962e4c0e1854b10612bab547c3d842c5f967dd23 Mon Sep 17 00:00:00 2001 From: Stefan Kerkmann Date: Wed, 14 Dec 2022 16:31:08 +0100 Subject: [Test] Reset timer for every unit test and provide timestamps for log messages (#17028) --- tests/basic/test_keycode_util.cpp | 52 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 tests/basic/test_keycode_util.cpp (limited to 'tests/basic') diff --git a/tests/basic/test_keycode_util.cpp b/tests/basic/test_keycode_util.cpp new file mode 100644 index 0000000000..693334676e --- /dev/null +++ b/tests/basic/test_keycode_util.cpp @@ -0,0 +1,52 @@ +// Copyright 2022 Stefan Kerkmann +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "test_common.hpp" + +class KeycodeToIdentifierSuite : public ::testing::TestWithParam> {}; + +TEST_P(KeycodeToIdentifierSuite, ConversionTests) { + ASSERT_EQ(get_keycode_identifier_or_default(GetParam().first), GetParam().second); +} + +INSTANTIATE_TEST_CASE_P(ConversionTestsP, KeycodeToIdentifierSuite, + // clang-format off +::testing::Values( + // Goto layer + std::make_pair(TO(0), "TO(0)"), + std::make_pair(TO(0x1F), "TO(31)"), + // Momentary switch layer + std::make_pair(MO(0), "MO(0)"), + std::make_pair(MO(0x1F), "MO(31)"), + // Set default layer + std::make_pair(DF(0), "DF(0)"), + std::make_pair(DF(0x1F), "DF(31)"), + // Toggle layer + std::make_pair(TG(0), "TG(0)"), + std::make_pair(TG(0x1F), "TG(31)"), + // One-shot layer + std::make_pair(OSL(0), "OSL(0)"), + std::make_pair(OSL(0x1F), "OSL(31)"), + // One-shot mod + std::make_pair(OSM(MOD_LSFT), "OSM(MOD_LSFT)"), + std::make_pair(OSM(MOD_LSFT | MOD_LCTL), "OSM(MOD_LCTL | MOD_LSFT)"), + // Layer Mod + std::make_pair(LM(0, MOD_LSFT), "LM(0, MOD_LSFT)"), + std::make_pair(LM(0xF, MOD_LSFT), "LM(15, MOD_LSFT)"), + std::make_pair(LM(0xF, MOD_LSFT | MOD_LCTL), "LM(15, MOD_LCTL | MOD_LSFT)"), + // Layer tap toggle + std::make_pair(TT(0), "TT(0)"), + std::make_pair(TT(0x1F), "TT(31)"), + // Layer tap + std::make_pair(LT(0, KC_A), "LT(0, KC_A)"), + std::make_pair(LT(0xF, KC_SPACE), "LT(15, KC_SPACE)"), + std::make_pair(LT(1, KC_SPC), "LT(1, KC_SPACE)"), + // Mod tap + std::make_pair(MT(MOD_LCTL, KC_A), "MT(MOD_LCTL, KC_A)"), + std::make_pair(MT(MOD_LCTL | MOD_LSFT, KC_A), "MT(MOD_LCTL | MOD_LSFT, KC_A)"), + std::make_pair(ALT_T(KC_TAB), "MT(MOD_LALT, KC_TAB)"), + // Mods + std::make_pair(LCTL(KC_A), "QK_MODS(KC_A, QK_LCTL)"), + std::make_pair(HYPR(KC_SPACE), "QK_MODS(KC_SPACE, QK_LCTL | QK_LSFT | QK_LALT | QK_LGUI)") +)); +// clang-format on -- cgit v1.2.3