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.
54 lines
1.0 KiB
54 lines
1.0 KiB
3 years ago
|
#include "ptlisp-test.h"
|
||
|
#include "../src/lisp.h"
|
||
|
|
||
|
START_TEST(cons_new_test) {
|
||
|
Pointer c = cons(69, 420);
|
||
|
ck_assert_uint_eq(CAR(c), 69);
|
||
|
ck_assert_uint_eq(CDR(c), 420);
|
||
|
}
|
||
|
END_TEST
|
||
|
|
||
|
START_TEST(cons_car_nil_test) {
|
||
|
ck_assert_uint_eq(car_fn(NIL), NIL);
|
||
|
}
|
||
|
END_TEST
|
||
|
|
||
|
START_TEST(cons_car_test) {
|
||
|
ck_assert_uint_eq(CAR(cons(69, 420)), 69);
|
||
|
}
|
||
|
END_TEST
|
||
|
|
||
|
START_TEST(cons_cdr_nil_test) {
|
||
|
ck_assert_uint_eq(CDR(NIL), NIL);
|
||
|
}
|
||
|
END_TEST
|
||
|
|
||
|
START_TEST(cons_cdr_test) {
|
||
|
ck_assert_uint_eq(CDR(cons(69, 420)), 420);
|
||
|
}
|
||
|
END_TEST
|
||
|
|
||
|
static void setup(void) {
|
||
|
memory_init(16);
|
||
|
symbol_init();
|
||
|
}
|
||
|
|
||
|
static void teardown(void) {
|
||
|
memory_free();
|
||
|
}
|
||
|
|
||
|
Suite* make_cons_test_suite(void) {
|
||
|
Suite *s1 = suite_create("Cons");
|
||
|
TCase *tc1_1 = tcase_create("Cons");
|
||
|
suite_add_tcase(s1, tc1_1);
|
||
|
|
||
|
tcase_add_checked_fixture(tc1_1, setup, teardown);
|
||
|
tcase_add_test(tc1_1, cons_new_test);
|
||
|
tcase_add_test(tc1_1, cons_car_nil_test);
|
||
|
tcase_add_test(tc1_1, cons_car_test);
|
||
|
tcase_add_test(tc1_1, cons_cdr_nil_test);
|
||
|
tcase_add_test(tc1_1, cons_cdr_test);
|
||
|
|
||
|
return s1;
|
||
|
}
|