test: TEST_INIT macro as a prologue for any unit test
This commit is contained in:
@@ -18,7 +18,7 @@
|
|||||||
#include "./test_vec.c"
|
#include "./test_vec.c"
|
||||||
|
|
||||||
test_suite_t SUITES[] = {
|
test_suite_t SUITES[] = {
|
||||||
VEC_SUITE, SV_SUITE, SYMTABLE_SUITE, STREAM_SUITE, LISP_API_SUITE,
|
SV_SUITE, VEC_SUITE, SYMTABLE_SUITE, STREAM_SUITE, LISP_API_SUITE,
|
||||||
};
|
};
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
@@ -29,7 +29,6 @@ int main(void)
|
|||||||
printf("Suite [%s]\n", suite.name);
|
printf("Suite [%s]\n", suite.name);
|
||||||
for (u64 j = 0; j < suite.size; ++j)
|
for (u64 j = 0; j < suite.size; ++j)
|
||||||
{
|
{
|
||||||
printf("\t[%s]: Running...\n", suite.tests[j].name);
|
|
||||||
suite.tests[j].fn();
|
suite.tests[j].fn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,9 @@
|
|||||||
#define TEST_VERBOSE 0
|
#define TEST_VERBOSE 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define TEST_INIT() printf("\t[%s]: Running...\n", __func__)
|
||||||
#define TEST_PASSED() printf("\t[%s]: Passed\n", __func__)
|
#define TEST_PASSED() printf("\t[%s]: Passed\n", __func__)
|
||||||
|
|
||||||
#if TEST_VERBOSE
|
#if TEST_VERBOSE
|
||||||
#define TEST(COND, ...) \
|
#define TEST(COND, ...) \
|
||||||
do \
|
do \
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
void smi_test(void)
|
void smi_test(void)
|
||||||
{
|
{
|
||||||
|
TEST_INIT();
|
||||||
// Standard old testing, checking both sides of the number line and our set
|
// Standard old testing, checking both sides of the number line and our set
|
||||||
// bounds.
|
// bounds.
|
||||||
i64 ints[] = {
|
i64 ints[] = {
|
||||||
@@ -32,6 +33,7 @@ void smi_test(void)
|
|||||||
|
|
||||||
void smi_oob_test(void)
|
void smi_oob_test(void)
|
||||||
{
|
{
|
||||||
|
TEST_INIT();
|
||||||
// These are integers that are completely out of the bounds of our standard
|
// These are integers that are completely out of the bounds of our standard
|
||||||
// tagging system due to their size. We need to use big integers for this.
|
// tagging system due to their size. We need to use big integers for this.
|
||||||
i64 ints[] = {
|
i64 ints[] = {
|
||||||
@@ -55,6 +57,7 @@ void smi_oob_test(void)
|
|||||||
|
|
||||||
void sym_fresh_test(void)
|
void sym_fresh_test(void)
|
||||||
{
|
{
|
||||||
|
TEST_INIT();
|
||||||
sys_t system = {0};
|
sys_t system = {0};
|
||||||
sys_init(&system);
|
sys_init(&system);
|
||||||
|
|
||||||
@@ -76,6 +79,7 @@ void sym_fresh_test(void)
|
|||||||
|
|
||||||
void sym_unique_test(void)
|
void sym_unique_test(void)
|
||||||
{
|
{
|
||||||
|
TEST_INIT();
|
||||||
sys_t system = {0};
|
sys_t system = {0};
|
||||||
sys_init(&system);
|
sys_init(&system);
|
||||||
|
|
||||||
@@ -107,6 +111,7 @@ void sym_unique_test(void)
|
|||||||
|
|
||||||
void cons_test(void)
|
void cons_test(void)
|
||||||
{
|
{
|
||||||
|
TEST_INIT();
|
||||||
sys_t system = {0};
|
sys_t system = {0};
|
||||||
sys_init(&system);
|
sys_init(&system);
|
||||||
|
|
||||||
@@ -143,6 +148,7 @@ void cons_test(void)
|
|||||||
|
|
||||||
void sys_test(void)
|
void sys_test(void)
|
||||||
{
|
{
|
||||||
|
TEST_INIT();
|
||||||
sys_t sys = {0};
|
sys_t sys = {0};
|
||||||
sys_init(&sys);
|
sys_init(&sys);
|
||||||
u64 old_memory_size = sys.memory.size;
|
u64 old_memory_size = sys.memory.size;
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
void stream_test_string(void)
|
void stream_test_string(void)
|
||||||
{
|
{
|
||||||
|
TEST_INIT();
|
||||||
sv_t test_strings[] = {
|
sv_t test_strings[] = {
|
||||||
SV("hello, world!", 13),
|
SV("hello, world!", 13),
|
||||||
SV("another string", 14),
|
SV("another string", 14),
|
||||||
@@ -54,36 +55,43 @@ void stream_test_string(void)
|
|||||||
|
|
||||||
void stream_test_file(void)
|
void stream_test_file(void)
|
||||||
{
|
{
|
||||||
|
TEST_INIT();
|
||||||
TODO("Not implemented");
|
TODO("Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
void stream_test_peek_next(void)
|
void stream_test_peek_next(void)
|
||||||
{
|
{
|
||||||
|
TEST_INIT();
|
||||||
TODO("Not implemented");
|
TODO("Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
void stream_test_seek(void)
|
void stream_test_seek(void)
|
||||||
{
|
{
|
||||||
|
TEST_INIT();
|
||||||
TODO("Not implemented");
|
TODO("Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
void stream_test_substr(void)
|
void stream_test_substr(void)
|
||||||
{
|
{
|
||||||
|
TEST_INIT();
|
||||||
TODO("Not implemented");
|
TODO("Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
void stream_test_till(void)
|
void stream_test_till(void)
|
||||||
{
|
{
|
||||||
|
TEST_INIT();
|
||||||
TODO("Not implemented");
|
TODO("Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
void stream_test_while(void)
|
void stream_test_while(void)
|
||||||
{
|
{
|
||||||
|
TEST_INIT();
|
||||||
TODO("Not implemented");
|
TODO("Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
void stream_test_line_col(void)
|
void stream_test_line_col(void)
|
||||||
{
|
{
|
||||||
|
TEST_INIT();
|
||||||
TODO("Not implemented");
|
TODO("Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
void sv_copy_test(void)
|
void sv_copy_test(void)
|
||||||
{
|
{
|
||||||
|
TEST_INIT();
|
||||||
static_assert(ARRSIZE(unique_words) > 3, "Expected at least 3 unique words");
|
static_assert(ARRSIZE(unique_words) > 3, "Expected at least 3 unique words");
|
||||||
for (u64 i = 0; i < 3; ++i)
|
for (u64 i = 0; i < 3; ++i)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
void symtable_test(void)
|
void symtable_test(void)
|
||||||
{
|
{
|
||||||
|
TEST_INIT();
|
||||||
sym_table_t table = {0};
|
sym_table_t table = {0};
|
||||||
sym_table_init(&table);
|
sym_table_init(&table);
|
||||||
for (u64 i = 0; i < ARRSIZE(words); ++i)
|
for (u64 i = 0; i < ARRSIZE(words); ++i)
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
void vec_test_concat(void)
|
void vec_test_concat(void)
|
||||||
{
|
{
|
||||||
|
TEST_INIT();
|
||||||
sys_t system = {0};
|
sys_t system = {0};
|
||||||
sys_init(&system);
|
sys_init(&system);
|
||||||
|
|
||||||
@@ -38,6 +39,7 @@ void vec_test_concat(void)
|
|||||||
|
|
||||||
void vec_test_substr(void)
|
void vec_test_substr(void)
|
||||||
{
|
{
|
||||||
|
TEST_INIT();
|
||||||
sys_t system = {0};
|
sys_t system = {0};
|
||||||
sys_init(&system);
|
sys_init(&system);
|
||||||
// Generating substrings
|
// Generating substrings
|
||||||
|
|||||||
Reference in New Issue
Block a user