From e65158a0326108d1fc724ee683b7fa900ef2671a Mon Sep 17 00:00:00 2001 From: Albert Cervin Date: Thu, 26 Jan 2023 13:07:07 +0100 Subject: More tests and documentation Also, split out platform-specific parts and add mocks for tests. --- test/main.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'test/main.c') diff --git a/test/main.c b/test/main.c index 8102a58..68241f9 100644 --- a/test/main.c +++ b/test/main.c @@ -1,7 +1,10 @@ #include #include +#include #include +#include +#include "bits/time.h" #include "test.h" void handle_abort() { exit(1); } @@ -10,6 +13,9 @@ int main() { setlocale(LC_ALL, ""); signal(SIGABRT, handle_abort); + struct timespec test_begin; + clock_gettime(CLOCK_MONOTONIC, &test_begin); + printf("\nšŸŒ \x1b[1;36mRunning utf8 tests...\x1b[0m\n"); run_utf8_tests(); @@ -22,6 +28,15 @@ int main() { printf("\nšŸ’ \x1b[1;36mRunning command tests...\x1b[0m\n"); run_command_tests(); - printf("\nšŸŽ‰ \x1b[1;32mDone! All tests successful!\x1b[0m\n"); + printf("\nšŸ“  \x1b[1;36mRunning keyboard tests...\x1b[0m\n"); + run_keyboard_tests(); + + struct timespec elapsed; + clock_gettime(CLOCK_MONOTONIC, &elapsed); + uint64_t elapsed_nanos = + ((uint64_t)elapsed.tv_sec * 1e9 + (uint64_t)elapsed.tv_nsec) - + ((uint64_t)test_begin.tv_sec * 1e9 + (uint64_t)test_begin.tv_nsec); + printf("\nšŸŽ‰ \x1b[1;32mDone! All tests successful in %.2f ms!\x1b[0m\n", + (double)elapsed_nanos / 1e6); return 0; } -- cgit v1.2.3