diff --git a/tests/unit/types/module.c b/tests/unit/types/module.c index 9d16b53..fe02d32 100644 --- a/tests/unit/types/module.c +++ b/tests/unit/types/module.c @@ -2,6 +2,7 @@ #include "err.h" #include "module.h" +#include "token.h" #include "unity.h" #include "utils.h" @@ -30,3 +31,19 @@ test_module_init_with_filepath_bigger_than_maximum_expects_to_truncate(void) TEST_ASSERT_EQUAL(MODULE_MAX_FILEPATH_SIZE, strlen(module.filepath)); } + +void +test_module_add_token(void) +{ + module_t module; + error_code_t err = module_init(&module, FILE_BASIC_MODULE); + TEST_ASSERT_EQUAL(ERR_OK, err); + + for (int i = 0; i < MODULE_INITIAL_TOKENS_LENGTH * 50; i++) { + token_t* token = module_add_token(&module); + + TEST_ASSERT_NOT_NULL(token); + + token_init(token, "keyword", TK_KEYWORD, 1, 2); + } +} diff --git a/tests/unit/types/test_types.c b/tests/unit/types/test_types.c index 51f2042..bb2eb38 100644 --- a/tests/unit/types/test_types.c +++ b/tests/unit/types/test_types.c @@ -12,6 +12,7 @@ main(void) RUN_TEST(test_module_init); RUN_TEST(test_module_init_with_filepath_bigger_than_maximum_expects_to_truncate); + RUN_TEST(test_module_add_token); return UNITY_END(); }