Minor refactor to parsing and testing cleanup

This commit is contained in:
2022-11-15 22:57:25 -05:00
parent 086d6f9106
commit 1595a6310d
5 changed files with 81 additions and 117 deletions

View File

@@ -43,11 +43,7 @@ static void test_token_next_lparen(void) {
const char *curr = input;
response = ucl_token_next(&curr);
TEST_ASSERT_NOT_NULL(response);
TEST_ASSERT_EQUAL(UCL_TYPE_CELL, response->type);
TEST_ASSERT_EQUAL(UCL_TYPE_SYMBOL, response->cell.car->type);
TEST_ASSERT_EQUAL_STRING("(", response->cell.car->string);
TEST_ASSERT_OBJ_SYMBOL_V(response, "(");
TEST_ASSERT_EQUAL('\0', *curr);
}
@@ -57,10 +53,7 @@ static void test_token_next_rparen(void) {
response = ucl_token_next(&curr);
TEST_ASSERT_NOT_NULL(response);
TEST_ASSERT_EQUAL(UCL_TYPE_CELL, response->type);
TEST_ASSERT_EQUAL(UCL_TYPE_SYMBOL, response->cell.car->type);
TEST_ASSERT_EQUAL_STRING(")", response->cell.car->string);
TEST_ASSERT_OBJ_SYMBOL_V(response, ")");
TEST_ASSERT_EQUAL('\0', *curr);
}
@@ -70,19 +63,12 @@ static void test_token_next_lrparen(void) {
response = ucl_token_next(&curr);
TEST_ASSERT_NOT_NULL(response);
TEST_ASSERT_EQUAL(UCL_TYPE_CELL, response->type);
TEST_ASSERT_EQUAL(UCL_TYPE_SYMBOL, response->cell.car->type);
TEST_ASSERT_EQUAL_STRING("(", response->cell.car->string);
TEST_ASSERT_EQUAL(')', *curr);
TEST_ASSERT_OBJ_SYMBOL_V(response, "(");
ucl_object_delete(response);
response = ucl_token_next(&curr);
TEST_ASSERT_NOT_NULL(response);
TEST_ASSERT_EQUAL(UCL_TYPE_CELL, response->type);
TEST_ASSERT_EQUAL(UCL_TYPE_SYMBOL, response->cell.car->type);
TEST_ASSERT_EQUAL_STRING(")", response->cell.car->string);
TEST_ASSERT_OBJ_SYMBOL_V(response, ")");
TEST_ASSERT_EQUAL('\0', *curr);
}
@@ -92,10 +78,7 @@ static void test_token_next_string(void) {
response = ucl_token_next(&curr);
TEST_ASSERT_NOT_NULL(response);
TEST_ASSERT_EQUAL(UCL_TYPE_CELL, response->type);
TEST_ASSERT_EQUAL(UCL_TYPE_STRING, response->cell.car->type);
TEST_ASSERT_EQUAL_STRING("foo", response->cell.car->string);
TEST_ASSERT_OBJ_STRING_V(response, "foo");
TEST_ASSERT_EQUAL('\0', *curr);
}
@@ -105,10 +88,7 @@ static void test_token_next_string_w_whitespace(void) {
response = ucl_token_next(&curr);
TEST_ASSERT_NOT_NULL(response);
TEST_ASSERT_EQUAL(UCL_TYPE_CELL, response->type);
TEST_ASSERT_EQUAL(UCL_TYPE_STRING, response->cell.car->type);
TEST_ASSERT_EQUAL_STRING("foo", response->cell.car->string);
TEST_ASSERT_OBJ_STRING_V(response, "foo");
TEST_ASSERT_EQUAL_STRING(" ", curr);
}
@@ -118,10 +98,7 @@ static void test_token_next_symbol(void) {
response = ucl_token_next(&curr);
TEST_ASSERT_NOT_NULL(response);
TEST_ASSERT_EQUAL(UCL_TYPE_CELL, response->type);
TEST_ASSERT_EQUAL(UCL_TYPE_SYMBOL, response->cell.car->type);
TEST_ASSERT_EQUAL_STRING("foo", response->cell.car->string);
TEST_ASSERT_OBJ_SYMBOL_V(response, "foo");
TEST_ASSERT_EQUAL_STRING("", curr);
}
@@ -131,17 +108,14 @@ static void test_token_next_symbol_w_whitespace(void) {
response = ucl_token_next(&curr);
TEST_ASSERT_NOT_NULL(response);
TEST_ASSERT_EQUAL(UCL_TYPE_CELL, response->type);
TEST_ASSERT_EQUAL(UCL_TYPE_SYMBOL, response->cell.car->type);
TEST_ASSERT_EQUAL_STRING("foo", response->cell.car->string);
TEST_ASSERT_OBJ_SYMBOL_V(response, "foo");
TEST_ASSERT_EQUAL_STRING(" ", curr);
}
static void test_tokenize_empty_str(void) {
response = ucl_tokenize("");
TEST_ASSERT_NULL(response);
TEST_ASSERT_NIL(response);
}
static void test_tokenize_nil(void) {