summaryrefslogtreecommitdiff
path: root/test/main.c
blob: dc0c2dc1f2b321b2249c0e5094a8a39b32fd038a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <locale.h>
#include <signal.h>
#include <stdint.h>
#include <stdlib.h>
#include <time.h>

#include "test.h"

void handle_abort() { exit(1); }

int main() {
  // Use a hardcoded locale to get a
  // predictable env.
  setlocale(LC_ALL, "en_US.UTF-8");
  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();

  printf("\nšŸ“œ \x1b[1;36mRunning text tests...\x1b[0m\n");
  run_text_tests();

  printf("\nāŖ \x1b[1;36mRunning undo tests...\x1b[0m\n");
  run_undo_tests();

  printf("\nšŸ•“ļø \x1b[1;36mRunning buffer tests...\x1b[0m\n");
  run_buffer_tests();

  printf("\nšŸ’ \x1b[1;36mRunning command tests...\x1b[0m\n");
  run_command_tests();

  printf("\nšŸ“  \x1b[1;36mRunning keyboard tests...\x1b[0m\n");
  run_keyboard_tests();

  printf("\nšŸ’¾ \x1b[1;36mRunning allocator tests...\x1b[0m\n");
  run_allocator_tests();

  printf("\n🐜 \x1b[1;36mRunning minibuffer tests...\x1b[0m\n");
  run_minibuffer_tests();

  printf("\n šŸ““ \x1b[1;36mRunning settings tests...\x1b[0m\n");
  run_settings_tests();

  printf("\n šŸŽ \x1b[1;36mRunning container tests...\x1b[0m\n");
  run_container_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;
}