mirror of
https://github.com/recp/cglm.git
synced 2025-10-03 16:51:35 +00:00
Custom Built-in Unit Test Suite (#105)
* tests: new built-in test runner * tests: update tests for new builtin test api * tests: print test suite logs * tests: remove cmocka from build files * tests: colorize test suite log and remove redundant prints
This commit is contained in:
68
test/runner.c
Normal file
68
test/runner.c
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
#include "include/common.h"
|
||||
#include "tests.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
int
|
||||
main(int argc, const char * argv[]) {
|
||||
test_entry_t *entry;
|
||||
test_status_t st;
|
||||
int32_t i, count, passed, failed;
|
||||
|
||||
passed = failed = 0;
|
||||
count = sizeof(tests) / sizeof(tests[0]);
|
||||
|
||||
fprintf(stderr, CYAN "\nWelcome to cglm tests\n\n" RESET);
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
entry = tests + i;
|
||||
st = entry->entry();
|
||||
|
||||
if (!st.status) {
|
||||
fprintf(stderr,
|
||||
BOLDRED " 𐄂" BOLDWHITE " %s " RESET,
|
||||
entry->name);
|
||||
if (st.msg) {
|
||||
fprintf(stderr,
|
||||
YELLOW "- %s" RESET,
|
||||
st.msg);
|
||||
}
|
||||
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
failed++;
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
GREEN " ✔︎" RESET " %s\n"
|
||||
,
|
||||
entry->name);
|
||||
passed++;
|
||||
}
|
||||
}
|
||||
|
||||
if (failed == 0) {
|
||||
fprintf(stderr, BOLDGREEN "\n All tests are passed 🎉\n" RESET);
|
||||
}
|
||||
|
||||
fprintf(stderr,
|
||||
CYAN "\ncglm test results:\n" RESET
|
||||
"------------------\n"
|
||||
|
||||
MAGENTA "%d" RESET " tests are runned, "
|
||||
GREEN "%d" RESET " %s passed, "
|
||||
RED "%d" RESET " %s failed\n\n" RESET,
|
||||
passed + failed,
|
||||
passed,
|
||||
passed > 1 ? "are" : "is",
|
||||
failed,
|
||||
failed > 1 ? "are" : "is");
|
||||
|
||||
return failed;
|
||||
}
|
Reference in New Issue
Block a user