mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-21 14:03:11 -07:00
parent
163fa81c03
commit
59e6603256
10 changed files with 272 additions and 108 deletions
|
@ -9,26 +9,51 @@ static MunitResult test_key_state(const MunitParameter params[], void *user)
|
|||
ChiakiKeyState state;
|
||||
chiaki_key_state_init(&state);
|
||||
|
||||
uint64_t pos = chiaki_key_state_request_pos(&state, 0);
|
||||
uint64_t pos = chiaki_key_state_request_pos(&state, 0, true);
|
||||
munit_assert_uint64(pos, ==, 0);
|
||||
pos = chiaki_key_state_request_pos(&state, 0x1337);
|
||||
pos = chiaki_key_state_request_pos(&state, 0x1337, true);
|
||||
munit_assert_uint64(pos, ==, 0x1337);
|
||||
pos = chiaki_key_state_request_pos(&state, 0xffff0000);
|
||||
pos = chiaki_key_state_request_pos(&state, 0xffff0000, true);
|
||||
munit_assert_uint64(pos, ==, 0xffff0000);
|
||||
pos = chiaki_key_state_request_pos(&state, 0x1337);
|
||||
pos = chiaki_key_state_request_pos(&state, 0x1337, true);
|
||||
munit_assert_uint64(pos, ==, 0x100001337);
|
||||
pos = chiaki_key_state_request_pos(&state, 0xffff1337);
|
||||
pos = chiaki_key_state_request_pos(&state, 0xffff1337, true);
|
||||
munit_assert_uint64(pos, ==, 0xffff1337);
|
||||
pos = chiaki_key_state_request_pos(&state, 0x50000000);
|
||||
pos = chiaki_key_state_request_pos(&state, 0x50000000, true);
|
||||
munit_assert_uint64(pos, ==, 0x150000000);
|
||||
pos = chiaki_key_state_request_pos(&state, 0xb0000000);
|
||||
pos = chiaki_key_state_request_pos(&state, 0xb0000000, true);
|
||||
munit_assert_uint64(pos, ==, 0x1b0000000);
|
||||
pos = chiaki_key_state_request_pos(&state, 0x00000000);
|
||||
pos = chiaki_key_state_request_pos(&state, 0x00000000, true);
|
||||
munit_assert_uint64(pos, ==, 0x200000000);
|
||||
|
||||
return MUNIT_OK;
|
||||
}
|
||||
|
||||
static MunitResult test_key_state_nocommit(const MunitParameter params[], void *user)
|
||||
{
|
||||
ChiakiKeyState state;
|
||||
chiaki_key_state_init(&state);
|
||||
|
||||
uint64_t pos = chiaki_key_state_request_pos(&state, 0, false);
|
||||
munit_assert_uint64(pos, ==, 0);
|
||||
pos = chiaki_key_state_request_pos(&state, 0x1337, false);
|
||||
munit_assert_uint64(pos, ==, 0x1337);
|
||||
pos = chiaki_key_state_request_pos(&state, 0xffff0000, false);
|
||||
munit_assert_uint64(pos, ==, 0xffff0000);
|
||||
pos = chiaki_key_state_request_pos(&state, 0x1337, false);
|
||||
munit_assert_uint64(pos, ==, 0x1337);
|
||||
pos = chiaki_key_state_request_pos(&state, 0xffff1337, false);
|
||||
munit_assert_uint64(pos, ==, 0xffff1337);
|
||||
pos = chiaki_key_state_request_pos(&state, 0x50000000, false);
|
||||
munit_assert_uint64(pos, ==, 0x50000000);
|
||||
pos = chiaki_key_state_request_pos(&state, 0xb0000000, false);
|
||||
munit_assert_uint64(pos, ==, 0xb0000000);
|
||||
pos = chiaki_key_state_request_pos(&state, 0x00000000, false);
|
||||
munit_assert_uint64(pos, ==, 0);
|
||||
|
||||
return MUNIT_OK;
|
||||
}
|
||||
|
||||
MunitTest tests_key_state[] = {
|
||||
{
|
||||
"/key_state",
|
||||
|
@ -38,5 +63,13 @@ MunitTest tests_key_state[] = {
|
|||
MUNIT_TEST_OPTION_NONE,
|
||||
NULL
|
||||
},
|
||||
{
|
||||
"/key_state_nocommit",
|
||||
test_key_state_nocommit,
|
||||
NULL,
|
||||
NULL,
|
||||
MUNIT_TEST_OPTION_NONE,
|
||||
NULL
|
||||
},
|
||||
{ NULL, NULL, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL }
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue