summaryrefslogtreecommitdiff
path: root/quantum/encoder/tests/encoder_tests.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/encoder/tests/encoder_tests.cpp')
-rw-r--r--quantum/encoder/tests/encoder_tests.cpp36
1 files changed, 18 insertions, 18 deletions
diff --git a/quantum/encoder/tests/encoder_tests.cpp b/quantum/encoder/tests/encoder_tests.cpp
index 1888fdab8d..b7c18aeec0 100644
--- a/quantum/encoder/tests/encoder_tests.cpp
+++ b/quantum/encoder/tests/encoder_tests.cpp
@@ -30,12 +30,12 @@ struct update {
bool clockwise;
};
-uint8_t uidx = 0;
+uint8_t updates_array_idx = 0;
update updates[32];
bool encoder_update_kb(uint8_t index, bool clockwise) {
- updates[uidx % 32] = {index, clockwise};
- uidx++;
+ updates[updates_array_idx % 32] = {index, clockwise};
+ updates_array_idx++;
return true;
}
@@ -47,15 +47,15 @@ bool setAndRead(pin_t pin, bool val) {
class EncoderTest : public ::testing::Test {};
TEST_F(EncoderTest, TestInit) {
- uidx = 0;
+ updates_array_idx = 0;
encoder_init();
EXPECT_EQ(pinIsInputHigh[0], true);
EXPECT_EQ(pinIsInputHigh[1], true);
- EXPECT_EQ(uidx, 0);
+ EXPECT_EQ(updates_array_idx, 0);
}
TEST_F(EncoderTest, TestOneClockwise) {
- uidx = 0;
+ updates_array_idx = 0;
encoder_init();
// send 4 pulses. with resolution 4, that's one step and we should get 1 update.
setAndRead(0, false);
@@ -63,26 +63,26 @@ TEST_F(EncoderTest, TestOneClockwise) {
setAndRead(0, true);
setAndRead(1, true);
- EXPECT_EQ(uidx, 1);
+ EXPECT_EQ(updates_array_idx, 1);
EXPECT_EQ(updates[0].index, 0);
EXPECT_EQ(updates[0].clockwise, true);
}
TEST_F(EncoderTest, TestOneCounterClockwise) {
- uidx = 0;
+ updates_array_idx = 0;
encoder_init();
setAndRead(1, false);
setAndRead(0, false);
setAndRead(1, true);
setAndRead(0, true);
- EXPECT_EQ(uidx, 1);
+ EXPECT_EQ(updates_array_idx, 1);
EXPECT_EQ(updates[0].index, 0);
EXPECT_EQ(updates[0].clockwise, false);
}
TEST_F(EncoderTest, TestTwoClockwiseOneCC) {
- uidx = 0;
+ updates_array_idx = 0;
encoder_init();
setAndRead(0, false);
setAndRead(1, false);
@@ -97,7 +97,7 @@ TEST_F(EncoderTest, TestTwoClockwiseOneCC) {
setAndRead(1, true);
setAndRead(0, true);
- EXPECT_EQ(uidx, 3);
+ EXPECT_EQ(updates_array_idx, 3);
EXPECT_EQ(updates[0].index, 0);
EXPECT_EQ(updates[0].clockwise, true);
EXPECT_EQ(updates[1].index, 0);
@@ -107,38 +107,38 @@ TEST_F(EncoderTest, TestTwoClockwiseOneCC) {
}
TEST_F(EncoderTest, TestNoEarly) {
- uidx = 0;
+ updates_array_idx = 0;
encoder_init();
// send 3 pulses. with resolution 4, that's not enough for a step.
setAndRead(0, false);
setAndRead(1, false);
setAndRead(0, true);
- EXPECT_EQ(uidx, 0);
+ EXPECT_EQ(updates_array_idx, 0);
// now send last pulse
setAndRead(1, true);
- EXPECT_EQ(uidx, 1);
+ EXPECT_EQ(updates_array_idx, 1);
EXPECT_EQ(updates[0].index, 0);
EXPECT_EQ(updates[0].clockwise, true);
}
TEST_F(EncoderTest, TestHalfway) {
- uidx = 0;
+ updates_array_idx = 0;
encoder_init();
// go halfway
setAndRead(0, false);
setAndRead(1, false);
- EXPECT_EQ(uidx, 0);
+ EXPECT_EQ(updates_array_idx, 0);
// back off
setAndRead(1, true);
setAndRead(0, true);
- EXPECT_EQ(uidx, 0);
+ EXPECT_EQ(updates_array_idx, 0);
// go all the way
setAndRead(0, false);
setAndRead(1, false);
setAndRead(0, true);
setAndRead(1, true);
// should result in 1 update
- EXPECT_EQ(uidx, 1);
+ EXPECT_EQ(updates_array_idx, 1);
EXPECT_EQ(updates[0].index, 0);
EXPECT_EQ(updates[0].clockwise, true);
}