#include "am.h" #include "unity.h" #define CAR(expr) (expr->pair.car) #define CDR(expr) (expr->pair.cdr) static am_t am; void setUp(void) { am_init(&am); } void tearDown(void) { } static void test_expr_value_restored_after_push_modify_pop(void) { expr_t a, b; am.expr = &a; am_push(&am); am.expr = &b; am_pop(&am); TEST_ASSERT_EQUAL(&a, am.expr); } static void test_append_arg_42_with_empty_argl(void) { am.argl = expr_empty_list(&am); am.val = expr_integer(&am, 42); am_append_arg(&am); TEST_ASSERT_FALSE(am.argl->is_atom); TEST_ASSERT_NOT_NULL(CAR(am.argl)); TEST_ASSERT_TRUE(CAR(am.argl)->is_atom); TEST_ASSERT_EQUAL(ATOM_TYPE_INTEGER, CAR(am.argl)->atom.type); TEST_ASSERT_EQUAL(42, CAR(am.argl)->atom.integer); TEST_ASSERT_TRUE(CDR(am.argl)->is_atom); TEST_ASSERT_EQUAL(ATOM_TYPE_EMPTY_LIST, CDR(am.argl)->atom.type); } int main(void) { UNITY_BEGIN(); RUN_TEST(test_expr_value_restored_after_push_modify_pop); RUN_TEST(test_append_arg_42_with_empty_argl); return UNITY_END(); }