2022-06-02 21:41:06 +03:00
|
|
|
/* This software is licensed by the MIT License, see LICENSE file */
|
|
|
|
|
/* Copyright © 2022 Gregory Lirent */
|
|
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include "../include/test.h"
|
|
|
|
|
#include "../include/time.h"
|
|
|
|
|
#include "../include/random.h"
|
|
|
|
|
|
|
|
|
|
static TIMER GLOBAL_TIMER;
|
|
|
|
|
static const char* TEST_NAME = 0;
|
|
|
|
|
|
|
|
|
|
static void test_uload() __attribute__((destructor));
|
|
|
|
|
|
|
|
|
|
static void test_uload() {
|
|
|
|
|
if (TEST_NAME) {
|
|
|
|
|
timer_stop(&GLOBAL_TIMER);
|
|
|
|
|
puts("");
|
|
|
|
|
put_separator();
|
|
|
|
|
printf("\e[36mTest \"\e[m\e[32;1m%s\e[m\e[36m\" is end.\nExecusion time: \e[m\e[32m%.6Lf sec\e[m\n", TEST_NAME, timer_value(&GLOBAL_TIMER));
|
|
|
|
|
put_separator();
|
|
|
|
|
timer_free(&GLOBAL_TIMER);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void put_separator() { puts("\e[37;2m=== === === === === === === ===\e[m"); }
|
|
|
|
|
|
|
|
|
|
void test_init(int argc, char** argv) {
|
|
|
|
|
timer_init(&GLOBAL_TIMER);
|
|
|
|
|
timer_start(&GLOBAL_TIMER);
|
|
|
|
|
|
|
|
|
|
TEST_NAME = strrchr(argv[0], '/') ? strrchr(argv[0], '/') + 1 : argv[0];
|
|
|
|
|
|
|
|
|
|
put_separator();
|
2022-06-03 14:09:11 +03:00
|
|
|
printf("\e[H\e[J\e[36mTest \"\e[m\e[32;1m%s\e[m\e[36m\" is loaded\e[m\n", TEST_NAME);
|
2022-06-02 21:41:06 +03:00
|
|
|
put_separator();
|
|
|
|
|
|
|
|
|
|
random_init(argc, argv);
|
|
|
|
|
|
|
|
|
|
puts("");
|
|
|
|
|
}
|