diff options
Diffstat (limited to 'tests/blogc/check_source_parser.c')
-rw-r--r-- | tests/blogc/check_source_parser.c | 91 |
1 files changed, 46 insertions, 45 deletions
diff --git a/tests/blogc/check_source_parser.c b/tests/blogc/check_source_parser.c index 4606673..8753687 100644 --- a/tests/blogc/check_source_parser.c +++ b/tests/blogc/check_source_parser.c @@ -11,9 +11,10 @@ #include <setjmp.h> #include <cmocka.h> #include <string.h> -#include "../../src/blogc/source-parser.h" -#include "../../src/blogc/error.h" +#include "../../src/common/error.h" #include "../../src/common/utils.h" +#include "../../src/blogc/errors.h" +#include "../../src/blogc/source-parser.h" static void @@ -26,7 +27,7 @@ test_source_parse(void **state) "# This is a test\n" "\n" "bola\n"; - blogc_error_t *err = NULL; + bc_error_t *err = NULL; bc_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(err); assert_non_null(source); @@ -58,7 +59,7 @@ test_source_parse_crlf(void **state) "# This is a test\r\n" "\r\n" "bola\r\n"; - blogc_error_t *err = NULL; + bc_error_t *err = NULL; bc_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(err); assert_non_null(source); @@ -92,7 +93,7 @@ test_source_parse_with_spaces(void **state) "# This is a test\n" "\n" "bola\n"; - blogc_error_t *err = NULL; + bc_error_t *err = NULL; bc_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(err); assert_non_null(source); @@ -129,7 +130,7 @@ test_source_parse_with_excerpt(void **state) "\n" "guda\n" "yay"; - blogc_error_t *err = NULL; + bc_error_t *err = NULL; bc_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(err); assert_non_null(source); @@ -169,7 +170,7 @@ test_source_parse_with_description(void **state) "# This is a test\n" "\n" "bola\n"; - blogc_error_t *err = NULL; + bc_error_t *err = NULL; bc_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(err); assert_non_null(source); @@ -195,13 +196,13 @@ static void test_source_parse_config_empty(void **state) { const char *a = ""; - blogc_error_t *err = NULL; + bc_error_t *err = NULL; bc_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(source); assert_non_null(err); assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER); assert_string_equal(err->msg, "Your source file is empty."); - blogc_error_free(err); + bc_error_free(err); bc_trie_free(source); } @@ -210,14 +211,14 @@ static void test_source_parse_config_invalid_key(void **state) { const char *a = "bola: guda"; - blogc_error_t *err = NULL; + bc_error_t *err = NULL; bc_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_non_null(err); assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER); assert_string_equal(err->msg, "Can't find a configuration key or the content separator.\n" "Error occurred near line 1, position 1: bola: guda"); - blogc_error_free(err); + bc_error_free(err); bc_trie_free(source); } @@ -226,14 +227,14 @@ static void test_source_parse_config_no_key(void **state) { const char *a = "BOLa"; - blogc_error_t *err = NULL; + bc_error_t *err = NULL; bc_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_non_null(err); assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER); assert_string_equal(err->msg, "Invalid configuration key.\n" "Error occurred near line 1, position 4: BOLa"); - blogc_error_free(err); + bc_error_free(err); bc_trie_free(source); } @@ -242,14 +243,14 @@ static void test_source_parse_config_no_key2(void **state) { const char *a = "BOLA"; - blogc_error_t *err = NULL; + bc_error_t *err = NULL; bc_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_non_null(err); assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER); assert_string_equal(err->msg, "Your last configuration key is missing ':' and the value\n" "Error occurred near line 1, position 5: BOLA"); - blogc_error_free(err); + bc_error_free(err); bc_trie_free(source); } @@ -258,7 +259,7 @@ static void test_source_parse_config_no_value(void **state) { const char *a = "BOLA:\r\n"; - blogc_error_t *err = NULL; + bc_error_t *err = NULL; bc_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(source); assert_non_null(err); @@ -266,7 +267,7 @@ test_source_parse_config_no_value(void **state) assert_string_equal(err->msg, "Configuration value not provided for 'BOLA'.\n" "Error occurred near line 1, position 6: BOLA:"); - blogc_error_free(err); + bc_error_free(err); bc_trie_free(source); } @@ -275,7 +276,7 @@ static void test_source_parse_config_no_value2(void **state) { const char *a = "BOLA:"; - blogc_error_t *err = NULL; + bc_error_t *err = NULL; bc_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(source); assert_non_null(err); @@ -283,7 +284,7 @@ test_source_parse_config_no_value2(void **state) assert_string_equal(err->msg, "Configuration value not provided for 'BOLA'.\n" "Error occurred near line 1, position 6: BOLA:"); - blogc_error_free(err); + bc_error_free(err); bc_trie_free(source); } @@ -292,7 +293,7 @@ static void test_source_parse_config_reserved_name(void **state) { const char *a = "FILENAME: asd\r\n"; - blogc_error_t *err = NULL; + bc_error_t *err = NULL; bc_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(source); assert_non_null(err); @@ -300,7 +301,7 @@ test_source_parse_config_reserved_name(void **state) assert_string_equal(err->msg, "'FILENAME' variable is forbidden in source files. It will be set " "for you by the compiler."); - blogc_error_free(err); + bc_error_free(err); bc_trie_free(source); } @@ -309,7 +310,7 @@ static void test_source_parse_config_reserved_name2(void **state) { const char *a = "CONTENT: asd\r\n"; - blogc_error_t *err = NULL; + bc_error_t *err = NULL; bc_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(source); assert_non_null(err); @@ -317,7 +318,7 @@ test_source_parse_config_reserved_name2(void **state) assert_string_equal(err->msg, "'CONTENT' variable is forbidden in source files. It will be set " "for you by the compiler."); - blogc_error_free(err); + bc_error_free(err); bc_trie_free(source); } @@ -326,7 +327,7 @@ static void test_source_parse_config_reserved_name3(void **state) { const char *a = "DATE_FORMATTED: asd\r\n"; - blogc_error_t *err = NULL; + bc_error_t *err = NULL; bc_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(source); assert_non_null(err); @@ -334,7 +335,7 @@ test_source_parse_config_reserved_name3(void **state) assert_string_equal(err->msg, "'DATE_FORMATTED' variable is forbidden in source files. It will be set " "for you by the compiler."); - blogc_error_free(err); + bc_error_free(err); bc_trie_free(source); } @@ -343,7 +344,7 @@ static void test_source_parse_config_reserved_name4(void **state) { const char *a = "DATE_FIRST_FORMATTED: asd\r\n"; - blogc_error_t *err = NULL; + bc_error_t *err = NULL; bc_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(source); assert_non_null(err); @@ -351,7 +352,7 @@ test_source_parse_config_reserved_name4(void **state) assert_string_equal(err->msg, "'DATE_FIRST_FORMATTED' variable is forbidden in source files. It will be set " "for you by the compiler."); - blogc_error_free(err); + bc_error_free(err); bc_trie_free(source); } @@ -360,7 +361,7 @@ static void test_source_parse_config_reserved_name5(void **state) { const char *a = "DATE_LAST_FORMATTED: asd\r\n"; - blogc_error_t *err = NULL; + bc_error_t *err = NULL; bc_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(source); assert_non_null(err); @@ -368,7 +369,7 @@ test_source_parse_config_reserved_name5(void **state) assert_string_equal(err->msg, "'DATE_LAST_FORMATTED' variable is forbidden in source files. It will be set " "for you by the compiler."); - blogc_error_free(err); + bc_error_free(err); bc_trie_free(source); } @@ -377,7 +378,7 @@ static void test_source_parse_config_reserved_name6(void **state) { const char *a = "PAGE_FIRST: asd\r\n"; - blogc_error_t *err = NULL; + bc_error_t *err = NULL; bc_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(source); assert_non_null(err); @@ -385,7 +386,7 @@ test_source_parse_config_reserved_name6(void **state) assert_string_equal(err->msg, "'PAGE_FIRST' variable is forbidden in source files. It will be set " "for you by the compiler."); - blogc_error_free(err); + bc_error_free(err); bc_trie_free(source); } @@ -394,7 +395,7 @@ static void test_source_parse_config_reserved_name7(void **state) { const char *a = "PAGE_PREVIOUS: asd\r\n"; - blogc_error_t *err = NULL; + bc_error_t *err = NULL; bc_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(source); assert_non_null(err); @@ -402,7 +403,7 @@ test_source_parse_config_reserved_name7(void **state) assert_string_equal(err->msg, "'PAGE_PREVIOUS' variable is forbidden in source files. It will be set " "for you by the compiler."); - blogc_error_free(err); + bc_error_free(err); bc_trie_free(source); } @@ -411,7 +412,7 @@ static void test_source_parse_config_reserved_name8(void **state) { const char *a = "PAGE_CURRENT: asd\r\n"; - blogc_error_t *err = NULL; + bc_error_t *err = NULL; bc_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(source); assert_non_null(err); @@ -419,7 +420,7 @@ test_source_parse_config_reserved_name8(void **state) assert_string_equal(err->msg, "'PAGE_CURRENT' variable is forbidden in source files. It will be set " "for you by the compiler."); - blogc_error_free(err); + bc_error_free(err); bc_trie_free(source); } @@ -428,7 +429,7 @@ static void test_source_parse_config_reserved_name9(void **state) { const char *a = "PAGE_NEXT: asd\r\n"; - blogc_error_t *err = NULL; + bc_error_t *err = NULL; bc_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(source); assert_non_null(err); @@ -436,7 +437,7 @@ test_source_parse_config_reserved_name9(void **state) assert_string_equal(err->msg, "'PAGE_NEXT' variable is forbidden in source files. It will be set " "for you by the compiler."); - blogc_error_free(err); + bc_error_free(err); bc_trie_free(source); } @@ -445,7 +446,7 @@ static void test_source_parse_config_reserved_name10(void **state) { const char *a = "PAGE_LAST: asd\r\n"; - blogc_error_t *err = NULL; + bc_error_t *err = NULL; bc_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(source); assert_non_null(err); @@ -453,7 +454,7 @@ test_source_parse_config_reserved_name10(void **state) assert_string_equal(err->msg, "'PAGE_LAST' variable is forbidden in source files. It will be set " "for you by the compiler."); - blogc_error_free(err); + bc_error_free(err); bc_trie_free(source); } @@ -462,7 +463,7 @@ static void test_source_parse_config_reserved_name11(void **state) { const char *a = "BLOGC_VERSION: 1.0\r\n"; - blogc_error_t *err = NULL; + bc_error_t *err = NULL; bc_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(source); assert_non_null(err); @@ -470,7 +471,7 @@ test_source_parse_config_reserved_name11(void **state) assert_string_equal(err->msg, "'BLOGC_VERSION' variable is forbidden in source files. It will be set " "for you by the compiler."); - blogc_error_free(err); + bc_error_free(err); bc_trie_free(source); } @@ -479,7 +480,7 @@ static void test_source_parse_config_value_no_line_ending(void **state) { const char *a = "BOLA: asd"; - blogc_error_t *err = NULL; + bc_error_t *err = NULL; bc_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(source); assert_non_null(err); @@ -487,7 +488,7 @@ test_source_parse_config_value_no_line_ending(void **state) assert_string_equal(err->msg, "No line ending after the configuration value for 'BOLA'.\n" "Error occurred near line 1, position 10: BOLA: asd"); - blogc_error_free(err); + bc_error_free(err); bc_trie_free(source); } @@ -496,7 +497,7 @@ static void test_source_parse_invalid_separator(void **state) { const char *a = "BOLA: asd\n---#"; - blogc_error_t *err = NULL; + bc_error_t *err = NULL; bc_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(source); assert_non_null(err); @@ -504,7 +505,7 @@ test_source_parse_invalid_separator(void **state) assert_string_equal(err->msg, "Invalid content separator. Must be more than one '-' characters.\n" "Error occurred near line 2, position 4: ---#"); - blogc_error_free(err); + bc_error_free(err); bc_trie_free(source); } |