summaryrefslogtreecommitdiff
path: root/test/main.c
diff options
context:
space:
mode:
authorAlbert Cervin <albert@acervin.com>2023-01-26 13:07:07 +0100
committerAlbert Cervin <albert@acervin.com>2023-01-26 13:07:07 +0100
commite65158a0326108d1fc724ee683b7fa900ef2671a (patch)
tree9bad30b377a326e0d0e3101c4f96228ae7a41673 /test/main.c
parent9a2b138a03e27d0f04101fe6ae3977d79518c513 (diff)
downloaddged-e65158a0326108d1fc724ee683b7fa900ef2671a.tar.gz
dged-e65158a0326108d1fc724ee683b7fa900ef2671a.tar.xz
dged-e65158a0326108d1fc724ee683b7fa900ef2671a.zip
More tests and documentation
Also, split out platform-specific parts and add mocks for tests.
Diffstat (limited to 'test/main.c')
-rw-r--r--test/main.c17
1 files changed, 16 insertions, 1 deletions
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 <locale.h>
#include <signal.h>
+#include <stdint.h>
#include <stdlib.h>
+#include <time.h>
+#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;
}