Refactor test plugs

This commit is contained in:
2022-06-06 22:07:35 +03:00
parent 4edaea54b3
commit 566de8019e
5 changed files with 83 additions and 48 deletions
+44
View File
@@ -24,6 +24,50 @@ static void test_uload() {
void put_separator() { puts("\e[37;2m=== === === === === === === ===\e[m"); }
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);
}
void print_container_value(const ssize_t* index, const void* value, const vtype type, _Bool print_type) {
if (index) {
printf("\e[32;1m%5ld: \e[m", *index);
} else fputs(" ", stdout);
printf("\e[31m%24s\e[m", libcdsb_vtype_stringify(value, type));
if (print_type) {
printf(" \e[36m(\e[m\e[32;1m%s\e[m\e[36m)\e[m", libcdsb_vtype_name(type));
}
puts("");
}
void print_container_info(const char* name, const char* el_name, const vtype* type, ssize_t size, ssize_t nmemb) {
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));
}
if (size >= 0 || nmemb >= 0) {
printf("\e[36m%s consists of \e[m", name);
}
if (size >= 0) {
printf("\e[32m%ld\e[m \e[36m%s", size, el_name);
if (nmemb >= 0) {
printf(" (\e[m\e[32m%ld bytes\e[m\e[36m)\e[m\n", nmemb);
} else puts("\e[m");
} else if (nmemb >= 0) {
printf("\e[32m%ld bytes\e[m\n", nmemb);
}
}
void test_init(int argc, char** argv) {
timer_init(&GLOBAL_TIMER);
timer_start(&GLOBAL_TIMER);