tests: split of symtable testing into its own suite
makes sense to be there, not in the lisp API
This commit is contained in:
@@ -12,9 +12,11 @@
|
|||||||
#include "./test.h"
|
#include "./test.h"
|
||||||
|
|
||||||
#include "./test_lisp_api.c"
|
#include "./test_lisp_api.c"
|
||||||
|
#include "./test_symtable.c"
|
||||||
#include "./test_vec.c"
|
#include "./test_vec.c"
|
||||||
|
|
||||||
test_suite_t SUITES[] = {
|
test_suite_t SUITES[] = {
|
||||||
|
SYMTABLE_SUITE,
|
||||||
LISP_API_SUITE,
|
LISP_API_SUITE,
|
||||||
VEC_SUITE,
|
VEC_SUITE,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -28,24 +28,6 @@ void int_test(void)
|
|||||||
TEST_PASSED();
|
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)
|
void sym_test(void)
|
||||||
{
|
{
|
||||||
sys_t system = {0};
|
sys_t system = {0};
|
||||||
|
|||||||
47
test/test_symtable.c
Normal file
47
test/test_symtable.c
Normal file
@@ -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 <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
*/
|
||||||
Reference in New Issue
Block a user