Skip to content

Commit

Permalink
test: add test case to module_add_token() function
Browse files Browse the repository at this point in the history
  • Loading branch information
Silva97 committed Jan 15, 2025
1 parent 0423005 commit 59871e8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/unit/types/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "err.h"
#include "module.h"
#include "token.h"
#include "unity.h"
#include "utils.h"

Expand Down Expand Up @@ -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);
}
}
1 change: 1 addition & 0 deletions tests/unit/types/test_types.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 59871e8

Please sign in to comment.