-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add tests for keyboard_get_keycodes consumer_press_release, add…
… testing for errors in some tests, add consumer code functions to squirrel_quantum
- Loading branch information
1 parent
ad246fc
commit 97665a0
Showing
11 changed files
with
246 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#include "squirrel.h" | ||
#include "squirrel_consumer.h" | ||
#include "squirrel_key.h" | ||
#include "squirrel_quantum.h" | ||
|
||
// test: consumer_press + consumer_release - in squirrel_quantum.c | ||
int main() { | ||
struct key test_key; // values unused | ||
enum squirrel_error err; | ||
for (uint16_t test_consumer_code = 0; test_consumer_code <= 65534; | ||
test_consumer_code++) { | ||
// consumer_press | ||
// no code becomes a code | ||
consumer_code = 0; | ||
err = consumer_press(&test_key, 0, 0, 1, test_consumer_code); | ||
if (err != ERR_NONE) { | ||
return 1; | ||
} | ||
if (consumer_code != test_consumer_code) { | ||
return 2; | ||
} | ||
// a code stays a code | ||
err = consumer_press(&test_key, 0, 0, 1, test_consumer_code); | ||
if (err != ERR_NONE) { | ||
return 3; | ||
} | ||
if (consumer_code != test_consumer_code) { | ||
return 4; | ||
} | ||
// another code becomes a code | ||
consumer_code = 0xFFFF; | ||
err = consumer_press(&test_key, 0, 0, 1, test_consumer_code); | ||
if (err != ERR_NONE) { | ||
return 5; | ||
} | ||
if (consumer_code != test_consumer_code) { | ||
return 6; | ||
} | ||
|
||
// consumer_release | ||
// a code becomes no code | ||
consumer_code = test_consumer_code; | ||
err = consumer_release(&test_key, 0, 0, 1, test_consumer_code); | ||
if (err != ERR_NONE) { | ||
return 7; | ||
} | ||
if (consumer_code != 0) { | ||
return 8; | ||
} | ||
// another code stays another code | ||
consumer_code = 0xFFFF; | ||
err = consumer_release(&test_key, 0, 0, 1, test_consumer_code); | ||
if (err != ERR_NONE) { | ||
return 9; | ||
} | ||
if (consumer_code != 0xFFFF) { | ||
return 10; | ||
} | ||
} | ||
|
||
// Test expected errors | ||
err = consumer_press(&test_key, 0, 0, 0, 0); | ||
if (err != ERR_KEY_FUNC_WRONG_ARGUMENT_COUNT) { | ||
return 11; | ||
} | ||
err = consumer_release(&test_key, 0, 0, 0, 0); | ||
if (err != ERR_KEY_FUNC_WRONG_ARGUMENT_COUNT) { | ||
return 12; | ||
} | ||
|
||
return 0; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include "squirrel.h" | ||
#include "squirrel_key.h" | ||
#include "squirrel_keyboard.h" | ||
#include "squirrel_quantum.h" | ||
|
||
// test: keyboard_get_keycodes - in squirrel_keyboard.c | ||
int main() { | ||
uint8_t active_keycodes[6] = {0, 0, 0, 0, 0, 0}; | ||
keyboard_get_keycodes(&active_keycodes); | ||
for (uint8_t i = 0; i < 6; i++) { | ||
if (active_keycodes[i] != 0) { | ||
return 1; | ||
} | ||
} | ||
for (int i = 0; i < 6; i++) { | ||
keyboard_keycodes[i] = true; | ||
} | ||
keyboard_get_keycodes(&active_keycodes); | ||
for (uint8_t i = 0; i < 6; i++) { | ||
if (active_keycodes[i] != i) { | ||
return 2; | ||
} | ||
} | ||
keyboard_keycodes[7] = true; | ||
keyboard_get_keycodes(&active_keycodes); | ||
for (uint8_t i = 0; i < 6; i++) { | ||
if (active_keycodes[i] != i) { | ||
return 3; | ||
} | ||
} | ||
return 0; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.