Update tests base
This commit is contained in:
+48
-29
@@ -1,6 +1,7 @@
|
||||
/* This software is licensed by the MIT License, see LICENSE file */
|
||||
/* Copyright © 2022 Gregory Lirent */
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include "../include/test.h"
|
||||
#include "../include/time.h"
|
||||
@@ -15,25 +16,59 @@ static void test_uload() {
|
||||
if (TEST_NAME) {
|
||||
timer_stop(&GLOBAL_TIMER);
|
||||
puts("");
|
||||
put_separator();
|
||||
put_separator(0);
|
||||
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();
|
||||
put_separator(0);
|
||||
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);
|
||||
|
||||
void print_container_values_prefix(const char* name, const char* prefix) {
|
||||
if (prefix) {
|
||||
printf("\e[36m%s %s values:\e[m\n", name, prefix);
|
||||
} else printf("\e[36m%s values:\e[m\n", name);
|
||||
TEST_NAME = strrchr(argv[0], '/') ? strrchr(argv[0], '/') + 1 : argv[0];
|
||||
|
||||
put_separator(0);
|
||||
printf("\e[H\e[J\e[36mTest \"\e[m\e[32;1m%s\e[m\e[36m\" is loaded\e[m\n", TEST_NAME);
|
||||
put_separator(0);
|
||||
|
||||
random_init(argc, argv);
|
||||
|
||||
puts("");
|
||||
}
|
||||
|
||||
void print_container_value(const ssize_t* index, const void* value, const vtype type, _Bool print_type) {
|
||||
void hp_printf(unsigned int hpos, const char* format, ...) {
|
||||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
vprintf(format, args);
|
||||
|
||||
printf("\e[%dG", hpos+1);
|
||||
|
||||
vprintf(format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
|
||||
void put_separator(unsigned int hpos) {
|
||||
printf("\e[%dG\e[37;2m=== === === === === === === ===\e[m\n", hpos+1);
|
||||
}
|
||||
|
||||
void print_container_values_prefix(const char* name, const char* prefix, unsigned int hpos) {
|
||||
if (prefix) {
|
||||
printf("\e[%dG\e[36m%s %s values:\e[m\n", hpos+1, name, prefix);
|
||||
} else {
|
||||
printf("\e[%dG\e[36m%s values:\e[m\n", hpos+1, name);
|
||||
}
|
||||
}
|
||||
|
||||
void print_container_value(const ssize_t* index, const void* value, const vtype type, _Bool print_type, unsigned int hpos) {
|
||||
if (index) {
|
||||
printf("\e[32;1m%5ld: \e[m", *index);
|
||||
} else fputs(" ", stdout);
|
||||
printf("\e[%dG\e[32;1m%5ld: \e[m", hpos+1, *index);
|
||||
} else {
|
||||
printf("\e[%dG ", hpos+1);
|
||||
}
|
||||
|
||||
printf("\e[31m%24s\e[m", libcdsb_vtype_stringify(value, type));
|
||||
|
||||
@@ -44,15 +79,15 @@ void print_container_value(const ssize_t* index, const void* value, const vtype
|
||||
puts("");
|
||||
}
|
||||
|
||||
void print_container_info(const char* name, const char* el_name, const vtype* type, ssize_t size, ssize_t nmemb) {
|
||||
void print_container_info(const char* name, const char* el_name, const vtype* type, ssize_t size, ssize_t nmemb, unsigned int hpos) {
|
||||
if (!el_name) el_name = "elements";
|
||||
|
||||
if (type) {
|
||||
printf("\e[36m%s initialized with type `\e[m\e[32;1m%s\e[m\e[36m`\n", name, libcdsb_vtype_name(*type));
|
||||
printf("\e[%dG\e[36m%s initialized with type `\e[m\e[32;1m%s\e[m\e[36m`\n", hpos+1, name, libcdsb_vtype_name(*type));
|
||||
}
|
||||
|
||||
if (size >= 0 || nmemb >= 0) {
|
||||
printf("\e[36m%s consists of \e[m", name);
|
||||
printf("\e[%dG\e[36m%s consists of \e[m", hpos+1, name);
|
||||
}
|
||||
|
||||
if (size >= 0) {
|
||||
@@ -66,19 +101,3 @@ void print_container_info(const char* name, const char* el_name, const vtype* ty
|
||||
printf("\e[32m%ld bytes\e[m\n", nmemb);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
printf("\e[H\e[J\e[36mTest \"\e[m\e[32;1m%s\e[m\e[36m\" is loaded\e[m\n", TEST_NAME);
|
||||
put_separator();
|
||||
|
||||
random_init(argc, argv);
|
||||
|
||||
puts("");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user