Fixed tests.

This commit is contained in:
Jacob Signorovitch 2024-10-05 09:35:33 -04:00
parent d244cfbfe1
commit 2008bab1f7
2 changed files with 16 additions and 7 deletions

View File

@ -3,17 +3,22 @@
#include "../src/include/token.h" #include "../src/include/token.h"
#include "registry.h" #include "registry.h"
#include "unity/unity_internals.h"
int test_token_init() { void test_token_init() {
UNITY_BEGIN();
char* s = malloc(sizeof("Hello, world!")); char* s = malloc(sizeof("Hello, world!"));
s = "Hello, world!"; s = "Hello, world!";
Token* t = token_init(TOKEN_TYPE_CALL, s); Token* t = token_init(TOKEN_TYPE_CALL, s);
TEST_ASSERT_EQUAL(TOKEN_TYPE_CALL, t->type); TEST_ASSERT_EQUAL(TOKEN_TYPE_CALL, t->type);
TEST_ASSERT_EQUAL_STRING("Hello, world!", t->val); TEST_ASSERT_EQUAL_STRING("Hello, world!", t->val);
}
int test_token() {
UNITY_BEGIN();
RUN_TEST(test_token_init);
return UNITY_END(); return UNITY_END();
} }
__attribute__((constructor)) void register_tests_token() { __attribute__((constructor)) void register_tests_token() {
register_test(test_token_init); register_test(test_token);
} }

View File

@ -2,13 +2,17 @@
#include "registry.h" #include "registry.h"
#include "unity/unity.h" #include "unity/unity.h"
int test_is_even() { void test_is_even() {
UNITY_BEGIN(); TEST_ASSERT_EQUAL(0, is_even(1));;
TEST_ASSERT_EQUAL(0, is_even(1));
TEST_ASSERT_EQUAL(1, is_even(2)); TEST_ASSERT_EQUAL(1, is_even(2));
}
int test_util() {
UNITY_BEGIN();
RUN_TEST(test_is_even);
return UNITY_END(); return UNITY_END();
} }
__attribute__((constructor)) void register_tests_util() { __attribute__((constructor)) void register_tests_util() {
register_test(test_is_even); register_test(test_util);
} }