diff options
author | Colin T.A. Gray <colinta@gmail.com> | 2017-12-15 00:15:52 +0100 |
---|---|---|
committer | Jack Humbert <jack.humb@gmail.com> | 2017-12-15 19:23:30 +0100 |
commit | 4ea3bbdb4cbb02310623c9dfc464d84e4f653492 (patch) | |
tree | 7914b5019cb55d0a343ec89385d95795f597cac5 /tests/basic | |
parent | bad839e6ac815f9fc0836d8170b716838fbc87b7 (diff) | |
download | qmk_firmware-4ea3bbdb4cbb02310623c9dfc464d84e4f653492.tar.gz qmk_firmware-4ea3bbdb4cbb02310623c9dfc464d84e4f653492.tar.xz |
add tests for action_layer.c and reset layer state after tests
Diffstat (limited to 'tests/basic')
-rw-r--r-- | tests/basic/test_action_layer.cpp | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/tests/basic/test_action_layer.cpp b/tests/basic/test_action_layer.cpp new file mode 100644 index 000000000..d00a0859b --- /dev/null +++ b/tests/basic/test_action_layer.cpp @@ -0,0 +1,92 @@ +/* Copyright 2017 Colin T.A. Gray + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "test_common.hpp" + +using testing::_; +using testing::Return; + +class ActionLayer : public TestFixture {}; + +// TEST_F(ActionLayer, LayerStateDBG) { +// layer_state_set(0); +// } + +// TEST_F(ActionLayer, LayerStateSet) { +// layer_state_set(0); +// EXPECT_EQ(layer_state, 0); +// layer_state_set(0b001100); +// EXPECT_EQ(layer_state, 0b001100); +// } + +// TEST_F(ActionLayer, LayerStateIs) { +// layer_state_set(0); +// EXPECT_EQ(layer_state_is(0), true); +// EXPECT_EQ(layer_state_is(1), true); +// layer_state_set(1); +// EXPECT_EQ(layer_state_is(0), true); +// EXPECT_EQ(layer_state_is(1), true); +// layer_state_set(2); +// EXPECT_EQ(layer_state_is(0), false); +// EXPECT_EQ(layer_state_is(1), false); +// EXPECT_EQ(layer_state_is(2), true); +// } + +TEST_F(ActionLayer, LayerStateCmp) { + uint32_t prev_layer; + + prev_layer = 0; + EXPECT_EQ(layer_state_cmp(prev_layer, 0), true); + EXPECT_EQ(layer_state_cmp(prev_layer, 1), false); + + prev_layer = 1; + EXPECT_EQ(layer_state_cmp(prev_layer, 0), true); + EXPECT_EQ(layer_state_cmp(prev_layer, 1), false); + + prev_layer = 2; + EXPECT_EQ(layer_state_cmp(prev_layer, 0), false); + EXPECT_EQ(layer_state_cmp(prev_layer, 1), true); + EXPECT_EQ(layer_state_cmp(prev_layer, 2), false); +} + +// TEST_F(ActionLayer, LayerClear) { +// layer_clear(); +// EXPECT_EQ(layer_state, 0); +// } + +// TEST_F(ActionLayer, LayerMove) { +// layer_move(0); +// EXPECT_EQ(layer_state, 1); +// layer_move(3); +// EXPECT_EQ(layer_state, 0b1000); +// } + +// TEST_F(ActionLayer, LayerOn) { +// layer_clear(); +// layer_on(1); +// layer_on(3); +// layer_on(3); +// EXPECT_EQ(layer_state, 0b1010); +// } + +// TEST_F(ActionLayer, LayerOff) { +// layer_clear(); +// layer_on(1); +// layer_on(3); +// layer_off(3); +// layer_off(2); +// EXPECT_EQ(layer_state, 0b1000); +// } |