Clean up many strdups

This commit is contained in:
2022-11-02 20:36:07 -04:00
parent 9c1a81811c
commit 3b7bef779b
11 changed files with 39 additions and 31 deletions

View File

@@ -103,6 +103,12 @@ static void test_eval_sym_undefined(void) {
TEST_ASSERT_OBJ_ERROR(response);
}
static void test_eval_nested_error(void) {
response = eval("(+ (error \"foo\") 3)");
TEST_ASSERT_OBJ_ERROR(response);
}
int main(void) {
UNITY_BEGIN();
@@ -117,6 +123,7 @@ int main(void) {
RUN_TEST(test_eval_string);
RUN_TEST(test_eval_sym_defined);
RUN_TEST(test_eval_sym_undefined);
RUN_TEST(test_eval_nested_error);
return UNITY_END();
}

View File

@@ -188,20 +188,20 @@ static void test_tokenize_statement(void) {
}
static void test_parse_atom_symbol(void) {
response = ucl_parse_token_atom(ucl_symbol_create(strdup("foo")));
response = ucl_parse_token_atom(ucl_symbol_create("foo"));
TEST_ASSERT_EQUAL(response->type, UCL_TYPE_SYMBOL);
TEST_ASSERT_EQUAL_STRING(response->symbol, "foo");
}
static void test_parse_atom_lparen(void) {
response = ucl_parse_token_atom(ucl_symbol_create(strdup("(")));
response = ucl_parse_token_atom(ucl_symbol_create("("));
TEST_ASSERT_NULL(response);
}
static void test_parse_atom_rparen(void) {
response = ucl_parse_token_atom(ucl_symbol_create(strdup(")")));
response = ucl_parse_token_atom(ucl_symbol_create(")"));
TEST_ASSERT_NULL(response);
}

View File

@@ -41,11 +41,11 @@ static void test_put2_get(void) {
static void test_put_modify_get(void) {
struct ucl_object *obj = ucl_tuple_create(
ucl_string_create(strdup("bar")),
ucl_string_create(strdup("baz")));
ucl_string_create("bar"),
ucl_string_create("baz"));
ucl_state_put(state, "foo", obj);
ucl_list_append(obj, ucl_string_create(strdup("quux")));
ucl_list_append(obj, ucl_string_create("quux"));
response = ucl_state_get(state, "foo");
TEST_ASSERT_OBJ_STRING(ucl_list_nth(response, 2));

View File

@@ -73,7 +73,7 @@ static void test_cdr_t(void) {
static void test_car_list(void) {
input = ucl_tuple_create(
ucl_string_create(strdup("foo")),
ucl_string_create("foo"),
ucl_t_create());
response = ucl_car(input);
@@ -83,7 +83,7 @@ static void test_car_list(void) {
static void test_cdr_list(void) {
input = ucl_tuple_create(
ucl_t_create(),
ucl_string_create(strdup("foo")));
ucl_string_create("foo"));
response = ucl_cdr(input);
TEST_ASSERT_OBJ_STRING(ucl_car(response));
@@ -146,7 +146,7 @@ static void test_list_nth_list_0() {
response = ucl_list_nth(
ucl_tuple_create(
ucl_t_create(),
ucl_string_create(strdup("foo"))),
ucl_string_create("foo")),
0);
TEST_ASSERT_T(response);
@@ -156,7 +156,7 @@ static void test_list_nth_list_1() {
response = ucl_list_nth(
ucl_tuple_create(
ucl_t_create(),
ucl_string_create(strdup("foo"))),
ucl_string_create("foo")),
1);
TEST_ASSERT_OBJ_STRING(response);