You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.6 KiB
62 lines
1.6 KiB
#include "ptlisp-test.h" |
|
#include "../src/lisp.h" |
|
|
|
|
|
START_TEST(sym_create_unexistant_empty_test) { |
|
char string[] = "Hello, world!"; |
|
Pointer a = symbol(string, sizeof(string)); |
|
|
|
char string2[] = "Goodbye, world!"; |
|
Pointer b = symbol(string2, sizeof(string2)); |
|
|
|
ck_assert_uint_ne(a, b); |
|
/* ck_assert_uint_eq(ARRAY(SYMBOLS).length, 2); */ |
|
/* ck_assert_uint_eq(array_get(SYMBOLS, 1), b); */ |
|
} |
|
END_TEST |
|
|
|
START_TEST(sym_create_unexistant_test) { |
|
char string[] = "Hello, world!"; |
|
size_t size = sizeof(string); |
|
Pointer sym = symbol(string, size); |
|
|
|
/* ck_assert_uint_eq(ARRAY(SYMBOLS).length, 1); */ |
|
/* ck_assert_uint_eq(array_get(SYMBOLS, 0), sym); */ |
|
ck_assert_uint_eq(SYMBOL(sym).length, size); |
|
} |
|
END_TEST |
|
|
|
START_TEST(sym_create_existant_test) { |
|
char string[] = "Hello, world!"; |
|
size_t size = sizeof(string); |
|
Pointer existant = symbol(string, size); |
|
Pointer sym = symbol(string, size); |
|
|
|
ck_assert_uint_eq(existant, sym); |
|
/* ck_assert_uint_eq(ARRAY(SYMBOLS).length, 1); */ |
|
/* ck_assert_uint_eq(array_get(SYMBOLS, 0), sym); */ |
|
ck_assert_uint_eq(SYMBOL(sym).length, size); |
|
} |
|
END_TEST |
|
|
|
static void setup(void) { |
|
memory_init(16); |
|
symbol_init(); |
|
} |
|
|
|
static void teardown(void) { |
|
memory_free(); |
|
} |
|
|
|
Suite* make_symbol_test_suite(void) { |
|
Suite *s1 = suite_create("Symbol"); |
|
TCase *tc1_1 = tcase_create("Symbol"); |
|
suite_add_tcase(s1, tc1_1); |
|
|
|
tcase_add_checked_fixture(tc1_1, setup, teardown); |
|
tcase_add_test(tc1_1, sym_create_unexistant_empty_test); |
|
tcase_add_test(tc1_1, sym_create_unexistant_test); |
|
tcase_add_test(tc1_1, sym_create_existant_test); |
|
|
|
return s1; |
|
}
|
|
|