Refactor with new name uclisp

This commit is contained in:
2022-10-28 23:19:19 -04:00
parent 26a0d17074
commit d97be8ec4b
22 changed files with 596 additions and 580 deletions

View File

@@ -2,57 +2,57 @@
#include <stdlib.h>
#include <string.h>
#include "nihilispm.h"
#include "nihilispm_internal.h"
#include "nihilispm_state.h"
#include "nihilispm_utility.h"
#include "uclisp.h"
#include "internal.h"
#include "state.h"
#include "utility.h"
#include "testing_helpers.h"
/* static struct nl_parse_result *result; */
static struct nl_state *state;
static struct nl_object *response;
/* static struct ucl_parse_result *result; */
static struct ucl_state *state;
static struct ucl_object *response;
void setUp(void) {
state = nl_state_create();
state = ucl_state_create();
}
void tearDown(void) {
nl_state_delete(state);
ucl_state_delete(state);
state = NULL;
}
static void test_get_empty(void) {
response = nl_state_get(state, "foo");
response = ucl_state_get(state, "foo");
TEST_ASSERT_OBJ_ERROR(response);
}
static void test_put_get(void) {
nl_state_put(state, "foo", nl_t_create());
response = nl_state_get(state, "foo");
ucl_state_put(state, "foo", ucl_t_create());
response = ucl_state_get(state, "foo");
TEST_ASSERT_T(response);
}
static void test_put2_get(void) {
nl_state_put(state, "foo1", nl_t_create());
nl_state_put(state, "foo2", nl_nil_create());
response = nl_state_get(state, "foo1");
ucl_state_put(state, "foo1", ucl_t_create());
ucl_state_put(state, "foo2", ucl_nil_create());
response = ucl_state_get(state, "foo1");
TEST_ASSERT_T(response);
}
static void test_put_modify_get(void) {
struct nl_object *obj = nl_tuple_create(
nl_string_create(strdup("bar")),
nl_string_create(strdup("baz")));
struct ucl_object *obj = ucl_tuple_create(
ucl_string_create(strdup("bar")),
ucl_string_create(strdup("baz")));
nl_state_put(state, "foo", obj);
nl_list_append(obj, nl_string_create(strdup("quux")));
response = nl_state_get(state, "foo");
ucl_state_put(state, "foo", obj);
ucl_list_append(obj, ucl_string_create(strdup("quux")));
response = ucl_state_get(state, "foo");
TEST_ASSERT_OBJ_STRING(nl_list_nth(response, 2));
TEST_ASSERT_EQUAL_STRING(nl_list_nth(response, 2)->string, "quux");
TEST_ASSERT_OBJ_STRING(ucl_list_nth(response, 2));
TEST_ASSERT_EQUAL_STRING(ucl_list_nth(response, 2)->string, "quux");
TEST_ASSERT_OBJ_STRING(nl_list_nth(obj, 2));
TEST_ASSERT_EQUAL_STRING(nl_list_nth(obj, 2)->string, "quux");
TEST_ASSERT_OBJ_STRING(ucl_list_nth(obj, 2));
TEST_ASSERT_EQUAL_STRING(ucl_list_nth(obj, 2)->string, "quux");
}