From 9095b118fd1c84571f4a6e441094e80e0c3c9813 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Thu, 5 Feb 2026 04:41:57 +0000 Subject: [PATCH] tests: split of symtable testing into its own suite makes sense to be there, not in the lisp API --- test/main.c | 2 ++ test/test_lisp_api.c | 18 ----------------- test/test_symtable.c | 47 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 18 deletions(-) create mode 100644 test/test_symtable.c diff --git a/test/main.c b/test/main.c index 29071ac..f4baf0b 100644 --- a/test/main.c +++ b/test/main.c @@ -12,9 +12,11 @@ #include "./test.h" #include "./test_lisp_api.c" +#include "./test_symtable.c" #include "./test_vec.c" test_suite_t SUITES[] = { + SYMTABLE_SUITE, LISP_API_SUITE, VEC_SUITE, }; diff --git a/test/test_lisp_api.c b/test/test_lisp_api.c index 0b02c30..3e0b15e 100644 --- a/test/test_lisp_api.c +++ b/test/test_lisp_api.c @@ -28,24 +28,6 @@ void int_test(void) TEST_PASSED(); } -void symtable_test(void) -{ - sym_table_t table = {0}; - sym_table_init(&table); - for (u64 i = 0; i < ARRSIZE(words); ++i) - sym_table_find(&table, SV((char *)words[i], strlen(words[i]))); - - TEST(table.count == ARRSIZE(unique_words), "%lu == %lu", table.count, - ARRSIZE(unique_words)); - - TEST(table.count < ARRSIZE(unique_words), "%lu < %lu", table.count, - ARRSIZE(unique_words)); - - TEST_PASSED(); - - sym_table_cleanup(&table); -} - void sym_test(void) { sys_t system = {0}; diff --git a/test/test_symtable.c b/test/test_symtable.c new file mode 100644 index 0000000..635adbd --- /dev/null +++ b/test/test_symtable.c @@ -0,0 +1,47 @@ +/* test_symtable.c: Symbol table tests + * Created: 2026-02-05 + * Author: Aryadev Chavali + * License: See end of file + * Commentary: + */ + +#include "./data.h" +#include "./test.h" + +void symtable_test(void) +{ + sym_table_t table = {0}; + sym_table_init(&table); + for (u64 i = 0; i < ARRSIZE(words); ++i) + sym_table_find(&table, SV((char *)words[i], strlen(words[i]))); + + TEST(table.count == ARRSIZE(unique_words), "%lu == %lu", table.count, + ARRSIZE(unique_words)); + + TEST_PASSED(); + + sym_table_cleanup(&table); +} + +const test_fn TESTS_SYMTABLE[] = { + MAKE_TEST_FN(symtable_test), +}; + +const test_suite_t SYMTABLE_SUITE = { + .name = "Symbol Table Tests", + .tests = TESTS_SYMTABLE, + .size = ARRSIZE(TESTS_SYMTABLE), +}; + +/* Copyright (C) 2026 Aryadev Chavali + + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License Version 2 for + * details. + + * You may distribute and modify this code under the terms of the GNU General + * Public License Version 2, which you should have received a copy of along with + * this program. If not, please go to . + + */