From 3b0f9293a3432023cdca91df01418347d9781ffa Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Fri, 26 Feb 2016 01:04:32 +0100 Subject: build: replace src/utils with squareball --- tests/check_source_parser.c | 142 ++++++++++++++++++++++---------------------- 1 file changed, 71 insertions(+), 71 deletions(-) (limited to 'tests/check_source_parser.c') diff --git a/tests/check_source_parser.c b/tests/check_source_parser.c index 8d6c039..a16a923 100644 --- a/tests/check_source_parser.c +++ b/tests/check_source_parser.c @@ -17,7 +17,7 @@ #include #include "../src/source-parser.h" #include "../src/error.h" -#include "../src/utils/utils.h" +#include static void @@ -31,23 +31,23 @@ test_source_parse(void **state) "\n" "bola\n"; blogc_error_t *err = NULL; - b_trie_t *source = blogc_source_parse(a, strlen(a), &err); + sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(err); assert_non_null(source); - assert_int_equal(b_trie_size(source), 5); - assert_string_equal(b_trie_lookup(source, "VAR1"), "asd asd"); - assert_string_equal(b_trie_lookup(source, "VAR2"), "123chunda"); - assert_string_equal(b_trie_lookup(source, "EXCERPT"), + assert_int_equal(sb_trie_size(source), 5); + assert_string_equal(sb_trie_lookup(source, "VAR1"), "asd asd"); + assert_string_equal(sb_trie_lookup(source, "VAR2"), "123chunda"); + assert_string_equal(sb_trie_lookup(source, "EXCERPT"), "

This is a test

\n" "

bola

\n"); - assert_string_equal(b_trie_lookup(source, "CONTENT"), + assert_string_equal(sb_trie_lookup(source, "CONTENT"), "

This is a test

\n" "

bola

\n"); - assert_string_equal(b_trie_lookup(source, "RAW_CONTENT"), + assert_string_equal(sb_trie_lookup(source, "RAW_CONTENT"), "# This is a test\n" "\n" "bola\n"); - b_trie_free(source); + sb_trie_free(source); } @@ -62,23 +62,23 @@ test_source_parse_crlf(void **state) "\r\n" "bola\r\n"; blogc_error_t *err = NULL; - b_trie_t *source = blogc_source_parse(a, strlen(a), &err); + sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(err); assert_non_null(source); - assert_int_equal(b_trie_size(source), 5); - assert_string_equal(b_trie_lookup(source, "VAR1"), "asd asd"); - assert_string_equal(b_trie_lookup(source, "VAR2"), "123chunda"); - assert_string_equal(b_trie_lookup(source, "EXCERPT"), + assert_int_equal(sb_trie_size(source), 5); + assert_string_equal(sb_trie_lookup(source, "VAR1"), "asd asd"); + assert_string_equal(sb_trie_lookup(source, "VAR2"), "123chunda"); + assert_string_equal(sb_trie_lookup(source, "EXCERPT"), "

This is a test

\r\n" "

bola

\r\n"); - assert_string_equal(b_trie_lookup(source, "CONTENT"), + assert_string_equal(sb_trie_lookup(source, "CONTENT"), "

This is a test

\r\n" "

bola

\r\n"); - assert_string_equal(b_trie_lookup(source, "RAW_CONTENT"), + assert_string_equal(sb_trie_lookup(source, "RAW_CONTENT"), "# This is a test\r\n" "\r\n" "bola\r\n"); - b_trie_free(source); + sb_trie_free(source); } @@ -95,23 +95,23 @@ test_source_parse_with_spaces(void **state) "\n" "bola\n"; blogc_error_t *err = NULL; - b_trie_t *source = blogc_source_parse(a, strlen(a), &err); + sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(err); assert_non_null(source); - assert_int_equal(b_trie_size(source), 5); - assert_string_equal(b_trie_lookup(source, "VAR1"), "chunda"); - assert_string_equal(b_trie_lookup(source, "BOLA"), "guda"); - assert_string_equal(b_trie_lookup(source, "EXCERPT"), + assert_int_equal(sb_trie_size(source), 5); + assert_string_equal(sb_trie_lookup(source, "VAR1"), "chunda"); + assert_string_equal(sb_trie_lookup(source, "BOLA"), "guda"); + assert_string_equal(sb_trie_lookup(source, "EXCERPT"), "

This is a test

\n" "

bola

\n"); - assert_string_equal(b_trie_lookup(source, "CONTENT"), + assert_string_equal(sb_trie_lookup(source, "CONTENT"), "

This is a test

\n" "

bola

\n"); - assert_string_equal(b_trie_lookup(source, "RAW_CONTENT"), + assert_string_equal(sb_trie_lookup(source, "RAW_CONTENT"), "# This is a test\n" "\n" "bola\n"); - b_trie_free(source); + sb_trie_free(source); } @@ -131,21 +131,21 @@ test_source_parse_with_excerpt(void **state) "guda\n" "yay"; blogc_error_t *err = NULL; - b_trie_t *source = blogc_source_parse(a, strlen(a), &err); + sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(err); assert_non_null(source); - assert_int_equal(b_trie_size(source), 5); - assert_string_equal(b_trie_lookup(source, "VAR1"), "asd asd"); - assert_string_equal(b_trie_lookup(source, "VAR2"), "123chunda"); - assert_string_equal(b_trie_lookup(source, "EXCERPT"), + assert_int_equal(sb_trie_size(source), 5); + assert_string_equal(sb_trie_lookup(source, "VAR1"), "asd asd"); + assert_string_equal(sb_trie_lookup(source, "VAR2"), "123chunda"); + assert_string_equal(sb_trie_lookup(source, "EXCERPT"), "

This is a test

\n" "

bola

\n"); - assert_string_equal(b_trie_lookup(source, "CONTENT"), + assert_string_equal(sb_trie_lookup(source, "CONTENT"), "

This is a test

\n" "

bola

\n" "

guda\n" "yay

\n"); - assert_string_equal(b_trie_lookup(source, "RAW_CONTENT"), + assert_string_equal(sb_trie_lookup(source, "RAW_CONTENT"), "# This is a test\n" "\n" "bola\n" @@ -154,7 +154,7 @@ test_source_parse_with_excerpt(void **state) "\n" "guda\n" "yay"); - b_trie_free(source); + sb_trie_free(source); } @@ -163,13 +163,13 @@ test_source_parse_config_empty(void **state) { const char *a = ""; blogc_error_t *err = NULL; - b_trie_t *source = blogc_source_parse(a, strlen(a), &err); + sb_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); - b_trie_free(source); + sb_trie_free(source); } @@ -178,14 +178,14 @@ test_source_parse_config_invalid_key(void **state) { const char *a = "bola: guda"; blogc_error_t *err = NULL; - b_trie_t *source = blogc_source_parse(a, strlen(a), &err); + sb_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); - b_trie_free(source); + sb_trie_free(source); } @@ -194,14 +194,14 @@ test_source_parse_config_no_key(void **state) { const char *a = "BOLa"; blogc_error_t *err = NULL; - b_trie_t *source = blogc_source_parse(a, strlen(a), &err); + sb_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); - b_trie_free(source); + sb_trie_free(source); } @@ -210,14 +210,14 @@ test_source_parse_config_no_key2(void **state) { const char *a = "BOLA"; blogc_error_t *err = NULL; - b_trie_t *source = blogc_source_parse(a, strlen(a), &err); + sb_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); - b_trie_free(source); + sb_trie_free(source); } @@ -226,7 +226,7 @@ test_source_parse_config_no_value(void **state) { const char *a = "BOLA:\r\n"; blogc_error_t *err = NULL; - b_trie_t *source = blogc_source_parse(a, strlen(a), &err); + sb_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); @@ -234,7 +234,7 @@ test_source_parse_config_no_value(void **state) "Configuration value not provided for 'BOLA'.\n" "Error occurred near line 1, position 6: BOLA:"); blogc_error_free(err); - b_trie_free(source); + sb_trie_free(source); } @@ -243,7 +243,7 @@ test_source_parse_config_no_value2(void **state) { const char *a = "BOLA:"; blogc_error_t *err = NULL; - b_trie_t *source = blogc_source_parse(a, strlen(a), &err); + sb_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); @@ -251,7 +251,7 @@ test_source_parse_config_no_value2(void **state) "Configuration value not provided for 'BOLA'.\n" "Error occurred near line 1, position 6: BOLA:"); blogc_error_free(err); - b_trie_free(source); + sb_trie_free(source); } @@ -260,7 +260,7 @@ test_source_parse_config_reserved_name(void **state) { const char *a = "FILENAME: asd\r\n"; blogc_error_t *err = NULL; - b_trie_t *source = blogc_source_parse(a, strlen(a), &err); + sb_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); @@ -268,7 +268,7 @@ test_source_parse_config_reserved_name(void **state) "'FILENAME' variable is forbidden in source files. It will be set " "for you by the compiler."); blogc_error_free(err); - b_trie_free(source); + sb_trie_free(source); } @@ -277,7 +277,7 @@ test_source_parse_config_reserved_name2(void **state) { const char *a = "CONTENT: asd\r\n"; blogc_error_t *err = NULL; - b_trie_t *source = blogc_source_parse(a, strlen(a), &err); + sb_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); @@ -285,7 +285,7 @@ test_source_parse_config_reserved_name2(void **state) "'CONTENT' variable is forbidden in source files. It will be set " "for you by the compiler."); blogc_error_free(err); - b_trie_free(source); + sb_trie_free(source); } @@ -294,7 +294,7 @@ test_source_parse_config_reserved_name3(void **state) { const char *a = "DATE_FORMATTED: asd\r\n"; blogc_error_t *err = NULL; - b_trie_t *source = blogc_source_parse(a, strlen(a), &err); + sb_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); @@ -302,7 +302,7 @@ test_source_parse_config_reserved_name3(void **state) "'DATE_FORMATTED' variable is forbidden in source files. It will be set " "for you by the compiler."); blogc_error_free(err); - b_trie_free(source); + sb_trie_free(source); } @@ -311,7 +311,7 @@ test_source_parse_config_reserved_name4(void **state) { const char *a = "DATE_FIRST_FORMATTED: asd\r\n"; blogc_error_t *err = NULL; - b_trie_t *source = blogc_source_parse(a, strlen(a), &err); + sb_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); @@ -319,7 +319,7 @@ test_source_parse_config_reserved_name4(void **state) "'DATE_FIRST_FORMATTED' variable is forbidden in source files. It will be set " "for you by the compiler."); blogc_error_free(err); - b_trie_free(source); + sb_trie_free(source); } @@ -328,7 +328,7 @@ test_source_parse_config_reserved_name5(void **state) { const char *a = "DATE_LAST_FORMATTED: asd\r\n"; blogc_error_t *err = NULL; - b_trie_t *source = blogc_source_parse(a, strlen(a), &err); + sb_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); @@ -336,7 +336,7 @@ test_source_parse_config_reserved_name5(void **state) "'DATE_LAST_FORMATTED' variable is forbidden in source files. It will be set " "for you by the compiler."); blogc_error_free(err); - b_trie_free(source); + sb_trie_free(source); } @@ -345,7 +345,7 @@ test_source_parse_config_reserved_name6(void **state) { const char *a = "PAGE_FIRST: asd\r\n"; blogc_error_t *err = NULL; - b_trie_t *source = blogc_source_parse(a, strlen(a), &err); + sb_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); @@ -353,7 +353,7 @@ test_source_parse_config_reserved_name6(void **state) "'PAGE_FIRST' variable is forbidden in source files. It will be set " "for you by the compiler."); blogc_error_free(err); - b_trie_free(source); + sb_trie_free(source); } @@ -362,7 +362,7 @@ test_source_parse_config_reserved_name7(void **state) { const char *a = "PAGE_PREVIOUS: asd\r\n"; blogc_error_t *err = NULL; - b_trie_t *source = blogc_source_parse(a, strlen(a), &err); + sb_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); @@ -370,7 +370,7 @@ test_source_parse_config_reserved_name7(void **state) "'PAGE_PREVIOUS' variable is forbidden in source files. It will be set " "for you by the compiler."); blogc_error_free(err); - b_trie_free(source); + sb_trie_free(source); } @@ -379,7 +379,7 @@ test_source_parse_config_reserved_name8(void **state) { const char *a = "PAGE_CURRENT: asd\r\n"; blogc_error_t *err = NULL; - b_trie_t *source = blogc_source_parse(a, strlen(a), &err); + sb_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); @@ -387,7 +387,7 @@ test_source_parse_config_reserved_name8(void **state) "'PAGE_CURRENT' variable is forbidden in source files. It will be set " "for you by the compiler."); blogc_error_free(err); - b_trie_free(source); + sb_trie_free(source); } @@ -396,7 +396,7 @@ test_source_parse_config_reserved_name9(void **state) { const char *a = "PAGE_NEXT: asd\r\n"; blogc_error_t *err = NULL; - b_trie_t *source = blogc_source_parse(a, strlen(a), &err); + sb_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); @@ -404,7 +404,7 @@ test_source_parse_config_reserved_name9(void **state) "'PAGE_NEXT' variable is forbidden in source files. It will be set " "for you by the compiler."); blogc_error_free(err); - b_trie_free(source); + sb_trie_free(source); } @@ -413,7 +413,7 @@ test_source_parse_config_reserved_name10(void **state) { const char *a = "PAGE_LAST: asd\r\n"; blogc_error_t *err = NULL; - b_trie_t *source = blogc_source_parse(a, strlen(a), &err); + sb_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); @@ -421,7 +421,7 @@ test_source_parse_config_reserved_name10(void **state) "'PAGE_LAST' variable is forbidden in source files. It will be set " "for you by the compiler."); blogc_error_free(err); - b_trie_free(source); + sb_trie_free(source); } @@ -430,7 +430,7 @@ test_source_parse_config_reserved_name11(void **state) { const char *a = "BLOGC_VERSION: 1.0\r\n"; blogc_error_t *err = NULL; - b_trie_t *source = blogc_source_parse(a, strlen(a), &err); + sb_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); @@ -438,7 +438,7 @@ test_source_parse_config_reserved_name11(void **state) "'BLOGC_VERSION' variable is forbidden in source files. It will be set " "for you by the compiler."); blogc_error_free(err); - b_trie_free(source); + sb_trie_free(source); } @@ -447,7 +447,7 @@ test_source_parse_config_value_no_line_ending(void **state) { const char *a = "BOLA: asd"; blogc_error_t *err = NULL; - b_trie_t *source = blogc_source_parse(a, strlen(a), &err); + sb_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); @@ -455,7 +455,7 @@ test_source_parse_config_value_no_line_ending(void **state) "No line ending after the configuration value for 'BOLA'.\n" "Error occurred near line 1, position 10: BOLA: asd"); blogc_error_free(err); - b_trie_free(source); + sb_trie_free(source); } @@ -464,7 +464,7 @@ test_source_parse_invalid_separator(void **state) { const char *a = "BOLA: asd\n---#"; blogc_error_t *err = NULL; - b_trie_t *source = blogc_source_parse(a, strlen(a), &err); + sb_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); @@ -472,7 +472,7 @@ test_source_parse_invalid_separator(void **state) "Invalid content separator. Must be more than one '-' characters.\n" "Error occurred near line 2, position 4: ---#"); blogc_error_free(err); - b_trie_free(source); + sb_trie_free(source); } -- cgit v1.2.3-18-g5258 From a2b3551dfb9460470bd79f5648bf597c517c40d4 Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Sun, 13 Mar 2016 01:48:49 +0100 Subject: *: use squareball error infrastructure --- tests/check_source_parser.c | 122 ++++++++++++++++++++++---------------------- 1 file changed, 61 insertions(+), 61 deletions(-) (limited to 'tests/check_source_parser.c') diff --git a/tests/check_source_parser.c b/tests/check_source_parser.c index a16a923..fba997a 100644 --- a/tests/check_source_parser.c +++ b/tests/check_source_parser.c @@ -30,7 +30,7 @@ test_source_parse(void **state) "# This is a test\n" "\n" "bola\n"; - blogc_error_t *err = NULL; + sb_error_t *err = NULL; sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(err); assert_non_null(source); @@ -61,7 +61,7 @@ test_source_parse_crlf(void **state) "# This is a test\r\n" "\r\n" "bola\r\n"; - blogc_error_t *err = NULL; + sb_error_t *err = NULL; sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(err); assert_non_null(source); @@ -94,7 +94,7 @@ test_source_parse_with_spaces(void **state) "# This is a test\n" "\n" "bola\n"; - blogc_error_t *err = NULL; + sb_error_t *err = NULL; sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(err); assert_non_null(source); @@ -130,7 +130,7 @@ test_source_parse_with_excerpt(void **state) "\n" "guda\n" "yay"; - blogc_error_t *err = NULL; + sb_error_t *err = NULL; sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(err); assert_non_null(source); @@ -162,13 +162,13 @@ static void test_source_parse_config_empty(void **state) { const char *a = ""; - blogc_error_t *err = NULL; + sb_error_t *err = NULL; sb_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_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER); assert_string_equal(err->msg, "Your source file is empty."); - blogc_error_free(err); + sb_error_free(err); sb_trie_free(source); } @@ -177,14 +177,14 @@ static void test_source_parse_config_invalid_key(void **state) { const char *a = "bola: guda"; - blogc_error_t *err = NULL; + sb_error_t *err = NULL; sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_non_null(err); - assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER); + assert_int_equal(err->code, 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); + sb_error_free(err); sb_trie_free(source); } @@ -193,14 +193,14 @@ static void test_source_parse_config_no_key(void **state) { const char *a = "BOLa"; - blogc_error_t *err = NULL; + sb_error_t *err = NULL; sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_non_null(err); - assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER); + assert_int_equal(err->code, 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); + sb_error_free(err); sb_trie_free(source); } @@ -209,14 +209,14 @@ static void test_source_parse_config_no_key2(void **state) { const char *a = "BOLA"; - blogc_error_t *err = NULL; + sb_error_t *err = NULL; sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_non_null(err); - assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER); + assert_int_equal(err->code, 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); + sb_error_free(err); sb_trie_free(source); } @@ -225,15 +225,15 @@ static void test_source_parse_config_no_value(void **state) { const char *a = "BOLA:\r\n"; - blogc_error_t *err = NULL; + sb_error_t *err = NULL; sb_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_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER); assert_string_equal(err->msg, "Configuration value not provided for 'BOLA'.\n" "Error occurred near line 1, position 6: BOLA:"); - blogc_error_free(err); + sb_error_free(err); sb_trie_free(source); } @@ -242,15 +242,15 @@ static void test_source_parse_config_no_value2(void **state) { const char *a = "BOLA:"; - blogc_error_t *err = NULL; + sb_error_t *err = NULL; sb_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_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER); assert_string_equal(err->msg, "Configuration value not provided for 'BOLA'.\n" "Error occurred near line 1, position 6: BOLA:"); - blogc_error_free(err); + sb_error_free(err); sb_trie_free(source); } @@ -259,15 +259,15 @@ static void test_source_parse_config_reserved_name(void **state) { const char *a = "FILENAME: asd\r\n"; - blogc_error_t *err = NULL; + sb_error_t *err = NULL; sb_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_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER); 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); + sb_error_free(err); sb_trie_free(source); } @@ -276,15 +276,15 @@ static void test_source_parse_config_reserved_name2(void **state) { const char *a = "CONTENT: asd\r\n"; - blogc_error_t *err = NULL; + sb_error_t *err = NULL; sb_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_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER); 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); + sb_error_free(err); sb_trie_free(source); } @@ -293,15 +293,15 @@ static void test_source_parse_config_reserved_name3(void **state) { const char *a = "DATE_FORMATTED: asd\r\n"; - blogc_error_t *err = NULL; + sb_error_t *err = NULL; sb_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_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER); 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); + sb_error_free(err); sb_trie_free(source); } @@ -310,15 +310,15 @@ static void test_source_parse_config_reserved_name4(void **state) { const char *a = "DATE_FIRST_FORMATTED: asd\r\n"; - blogc_error_t *err = NULL; + sb_error_t *err = NULL; sb_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_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER); 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); + sb_error_free(err); sb_trie_free(source); } @@ -327,15 +327,15 @@ static void test_source_parse_config_reserved_name5(void **state) { const char *a = "DATE_LAST_FORMATTED: asd\r\n"; - blogc_error_t *err = NULL; + sb_error_t *err = NULL; sb_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_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER); 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); + sb_error_free(err); sb_trie_free(source); } @@ -344,15 +344,15 @@ static void test_source_parse_config_reserved_name6(void **state) { const char *a = "PAGE_FIRST: asd\r\n"; - blogc_error_t *err = NULL; + sb_error_t *err = NULL; sb_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_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER); 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); + sb_error_free(err); sb_trie_free(source); } @@ -361,15 +361,15 @@ static void test_source_parse_config_reserved_name7(void **state) { const char *a = "PAGE_PREVIOUS: asd\r\n"; - blogc_error_t *err = NULL; + sb_error_t *err = NULL; sb_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_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER); 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); + sb_error_free(err); sb_trie_free(source); } @@ -378,15 +378,15 @@ static void test_source_parse_config_reserved_name8(void **state) { const char *a = "PAGE_CURRENT: asd\r\n"; - blogc_error_t *err = NULL; + sb_error_t *err = NULL; sb_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_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER); 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); + sb_error_free(err); sb_trie_free(source); } @@ -395,15 +395,15 @@ static void test_source_parse_config_reserved_name9(void **state) { const char *a = "PAGE_NEXT: asd\r\n"; - blogc_error_t *err = NULL; + sb_error_t *err = NULL; sb_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_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER); 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); + sb_error_free(err); sb_trie_free(source); } @@ -412,15 +412,15 @@ static void test_source_parse_config_reserved_name10(void **state) { const char *a = "PAGE_LAST: asd\r\n"; - blogc_error_t *err = NULL; + sb_error_t *err = NULL; sb_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_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER); 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); + sb_error_free(err); sb_trie_free(source); } @@ -429,15 +429,15 @@ static void test_source_parse_config_reserved_name11(void **state) { const char *a = "BLOGC_VERSION: 1.0\r\n"; - blogc_error_t *err = NULL; + sb_error_t *err = NULL; sb_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_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER); 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); + sb_error_free(err); sb_trie_free(source); } @@ -446,15 +446,15 @@ static void test_source_parse_config_value_no_line_ending(void **state) { const char *a = "BOLA: asd"; - blogc_error_t *err = NULL; + sb_error_t *err = NULL; sb_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_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER); 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); + sb_error_free(err); sb_trie_free(source); } @@ -463,15 +463,15 @@ static void test_source_parse_invalid_separator(void **state) { const char *a = "BOLA: asd\n---#"; - blogc_error_t *err = NULL; + sb_error_t *err = NULL; sb_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_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER); 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); + sb_error_free(err); sb_trie_free(source); } -- cgit v1.2.3-18-g5258 From 9b2a563b4931ca39cd6dd14bf85cda627714a4b2 Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Wed, 20 Apr 2016 02:50:20 +0200 Subject: content-parser: extract post description from content description is the first line of the first paragraph parsed from content file. users can override it declaring DESCRIPTION variable in source file itself. this also fixes a bug with line endings when using single line blockquotes. --- tests/check_source_parser.c | 46 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) (limited to 'tests/check_source_parser.c') diff --git a/tests/check_source_parser.c b/tests/check_source_parser.c index fba997a..a2a3ddc 100644 --- a/tests/check_source_parser.c +++ b/tests/check_source_parser.c @@ -34,7 +34,7 @@ test_source_parse(void **state) sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(err); assert_non_null(source); - assert_int_equal(sb_trie_size(source), 5); + assert_int_equal(sb_trie_size(source), 6); assert_string_equal(sb_trie_lookup(source, "VAR1"), "asd asd"); assert_string_equal(sb_trie_lookup(source, "VAR2"), "123chunda"); assert_string_equal(sb_trie_lookup(source, "EXCERPT"), @@ -47,6 +47,7 @@ test_source_parse(void **state) "# This is a test\n" "\n" "bola\n"); + assert_string_equal(sb_trie_lookup(source, "DESCRIPTION"), "bola"); sb_trie_free(source); } @@ -65,7 +66,7 @@ test_source_parse_crlf(void **state) sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(err); assert_non_null(source); - assert_int_equal(sb_trie_size(source), 5); + assert_int_equal(sb_trie_size(source), 6); assert_string_equal(sb_trie_lookup(source, "VAR1"), "asd asd"); assert_string_equal(sb_trie_lookup(source, "VAR2"), "123chunda"); assert_string_equal(sb_trie_lookup(source, "EXCERPT"), @@ -78,6 +79,7 @@ test_source_parse_crlf(void **state) "# This is a test\r\n" "\r\n" "bola\r\n"); + assert_string_equal(sb_trie_lookup(source, "DESCRIPTION"), "bola"); sb_trie_free(source); } @@ -98,7 +100,7 @@ test_source_parse_with_spaces(void **state) sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(err); assert_non_null(source); - assert_int_equal(sb_trie_size(source), 5); + assert_int_equal(sb_trie_size(source), 6); assert_string_equal(sb_trie_lookup(source, "VAR1"), "chunda"); assert_string_equal(sb_trie_lookup(source, "BOLA"), "guda"); assert_string_equal(sb_trie_lookup(source, "EXCERPT"), @@ -111,6 +113,7 @@ test_source_parse_with_spaces(void **state) "# This is a test\n" "\n" "bola\n"); + assert_string_equal(sb_trie_lookup(source, "DESCRIPTION"), "bola"); sb_trie_free(source); } @@ -134,7 +137,7 @@ test_source_parse_with_excerpt(void **state) sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(err); assert_non_null(source); - assert_int_equal(sb_trie_size(source), 5); + assert_int_equal(sb_trie_size(source), 6); assert_string_equal(sb_trie_lookup(source, "VAR1"), "asd asd"); assert_string_equal(sb_trie_lookup(source, "VAR2"), "123chunda"); assert_string_equal(sb_trie_lookup(source, "EXCERPT"), @@ -154,6 +157,40 @@ test_source_parse_with_excerpt(void **state) "\n" "guda\n" "yay"); + assert_string_equal(sb_trie_lookup(source, "DESCRIPTION"), "bola"); + sb_trie_free(source); +} + + +static void +test_source_parse_with_description(void **state) +{ + const char *a = + "VAR1: asd asd\n" + "VAR2: 123chunda\n" + "DESCRIPTION: huehuehuebrbr\n" + "----------\n" + "# This is a test\n" + "\n" + "bola\n"; + sb_error_t *err = NULL; + sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); + assert_null(err); + assert_non_null(source); + assert_int_equal(sb_trie_size(source), 6); + assert_string_equal(sb_trie_lookup(source, "VAR1"), "asd asd"); + assert_string_equal(sb_trie_lookup(source, "VAR2"), "123chunda"); + assert_string_equal(sb_trie_lookup(source, "EXCERPT"), + "

This is a test

\n" + "

bola

\n"); + assert_string_equal(sb_trie_lookup(source, "CONTENT"), + "

This is a test

\n" + "

bola

\n"); + assert_string_equal(sb_trie_lookup(source, "RAW_CONTENT"), + "# This is a test\n" + "\n" + "bola\n"); + assert_string_equal(sb_trie_lookup(source, "DESCRIPTION"), "huehuehuebrbr"); sb_trie_free(source); } @@ -484,6 +521,7 @@ main(void) unit_test(test_source_parse_crlf), unit_test(test_source_parse_with_spaces), unit_test(test_source_parse_with_excerpt), + unit_test(test_source_parse_with_description), unit_test(test_source_parse_config_empty), unit_test(test_source_parse_config_invalid_key), unit_test(test_source_parse_config_no_key), -- cgit v1.2.3-18-g5258 From 6153580a13e7e7c48e38fa446572c8adcae08084 Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Wed, 27 Apr 2016 01:31:02 +0200 Subject: Revert "*: use squareball error infrastructure" This reverts commit a2b3551dfb9460470bd79f5648bf597c517c40d4. --- tests/check_source_parser.c | 122 ++++++++++++++++++++++---------------------- 1 file changed, 61 insertions(+), 61 deletions(-) (limited to 'tests/check_source_parser.c') diff --git a/tests/check_source_parser.c b/tests/check_source_parser.c index a2a3ddc..0f891dd 100644 --- a/tests/check_source_parser.c +++ b/tests/check_source_parser.c @@ -30,7 +30,7 @@ test_source_parse(void **state) "# This is a test\n" "\n" "bola\n"; - sb_error_t *err = NULL; + blogc_error_t *err = NULL; sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(err); assert_non_null(source); @@ -62,7 +62,7 @@ test_source_parse_crlf(void **state) "# This is a test\r\n" "\r\n" "bola\r\n"; - sb_error_t *err = NULL; + blogc_error_t *err = NULL; sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(err); assert_non_null(source); @@ -96,7 +96,7 @@ test_source_parse_with_spaces(void **state) "# This is a test\n" "\n" "bola\n"; - sb_error_t *err = NULL; + blogc_error_t *err = NULL; sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(err); assert_non_null(source); @@ -133,7 +133,7 @@ test_source_parse_with_excerpt(void **state) "\n" "guda\n" "yay"; - sb_error_t *err = NULL; + blogc_error_t *err = NULL; sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(err); assert_non_null(source); @@ -199,13 +199,13 @@ static void test_source_parse_config_empty(void **state) { const char *a = ""; - sb_error_t *err = NULL; + blogc_error_t *err = NULL; sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(source); assert_non_null(err); - assert_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER); + assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER); assert_string_equal(err->msg, "Your source file is empty."); - sb_error_free(err); + blogc_error_free(err); sb_trie_free(source); } @@ -214,14 +214,14 @@ static void test_source_parse_config_invalid_key(void **state) { const char *a = "bola: guda"; - sb_error_t *err = NULL; + blogc_error_t *err = NULL; sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_non_null(err); - assert_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER); + 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"); - sb_error_free(err); + blogc_error_free(err); sb_trie_free(source); } @@ -230,14 +230,14 @@ static void test_source_parse_config_no_key(void **state) { const char *a = "BOLa"; - sb_error_t *err = NULL; + blogc_error_t *err = NULL; sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_non_null(err); - assert_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER); + 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"); - sb_error_free(err); + blogc_error_free(err); sb_trie_free(source); } @@ -246,14 +246,14 @@ static void test_source_parse_config_no_key2(void **state) { const char *a = "BOLA"; - sb_error_t *err = NULL; + blogc_error_t *err = NULL; sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_non_null(err); - assert_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER); + 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"); - sb_error_free(err); + blogc_error_free(err); sb_trie_free(source); } @@ -262,15 +262,15 @@ static void test_source_parse_config_no_value(void **state) { const char *a = "BOLA:\r\n"; - sb_error_t *err = NULL; + blogc_error_t *err = NULL; sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(source); assert_non_null(err); - assert_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER); + assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER); assert_string_equal(err->msg, "Configuration value not provided for 'BOLA'.\n" "Error occurred near line 1, position 6: BOLA:"); - sb_error_free(err); + blogc_error_free(err); sb_trie_free(source); } @@ -279,15 +279,15 @@ static void test_source_parse_config_no_value2(void **state) { const char *a = "BOLA:"; - sb_error_t *err = NULL; + blogc_error_t *err = NULL; sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(source); assert_non_null(err); - assert_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER); + assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER); assert_string_equal(err->msg, "Configuration value not provided for 'BOLA'.\n" "Error occurred near line 1, position 6: BOLA:"); - sb_error_free(err); + blogc_error_free(err); sb_trie_free(source); } @@ -296,15 +296,15 @@ static void test_source_parse_config_reserved_name(void **state) { const char *a = "FILENAME: asd\r\n"; - sb_error_t *err = NULL; + blogc_error_t *err = NULL; sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(source); assert_non_null(err); - assert_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER); + assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER); assert_string_equal(err->msg, "'FILENAME' variable is forbidden in source files. It will be set " "for you by the compiler."); - sb_error_free(err); + blogc_error_free(err); sb_trie_free(source); } @@ -313,15 +313,15 @@ static void test_source_parse_config_reserved_name2(void **state) { const char *a = "CONTENT: asd\r\n"; - sb_error_t *err = NULL; + blogc_error_t *err = NULL; sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(source); assert_non_null(err); - assert_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER); + assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER); assert_string_equal(err->msg, "'CONTENT' variable is forbidden in source files. It will be set " "for you by the compiler."); - sb_error_free(err); + blogc_error_free(err); sb_trie_free(source); } @@ -330,15 +330,15 @@ static void test_source_parse_config_reserved_name3(void **state) { const char *a = "DATE_FORMATTED: asd\r\n"; - sb_error_t *err = NULL; + blogc_error_t *err = NULL; sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(source); assert_non_null(err); - assert_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER); + assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER); assert_string_equal(err->msg, "'DATE_FORMATTED' variable is forbidden in source files. It will be set " "for you by the compiler."); - sb_error_free(err); + blogc_error_free(err); sb_trie_free(source); } @@ -347,15 +347,15 @@ static void test_source_parse_config_reserved_name4(void **state) { const char *a = "DATE_FIRST_FORMATTED: asd\r\n"; - sb_error_t *err = NULL; + blogc_error_t *err = NULL; sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(source); assert_non_null(err); - assert_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER); + assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER); assert_string_equal(err->msg, "'DATE_FIRST_FORMATTED' variable is forbidden in source files. It will be set " "for you by the compiler."); - sb_error_free(err); + blogc_error_free(err); sb_trie_free(source); } @@ -364,15 +364,15 @@ static void test_source_parse_config_reserved_name5(void **state) { const char *a = "DATE_LAST_FORMATTED: asd\r\n"; - sb_error_t *err = NULL; + blogc_error_t *err = NULL; sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(source); assert_non_null(err); - assert_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER); + assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER); assert_string_equal(err->msg, "'DATE_LAST_FORMATTED' variable is forbidden in source files. It will be set " "for you by the compiler."); - sb_error_free(err); + blogc_error_free(err); sb_trie_free(source); } @@ -381,15 +381,15 @@ static void test_source_parse_config_reserved_name6(void **state) { const char *a = "PAGE_FIRST: asd\r\n"; - sb_error_t *err = NULL; + blogc_error_t *err = NULL; sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(source); assert_non_null(err); - assert_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER); + assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER); assert_string_equal(err->msg, "'PAGE_FIRST' variable is forbidden in source files. It will be set " "for you by the compiler."); - sb_error_free(err); + blogc_error_free(err); sb_trie_free(source); } @@ -398,15 +398,15 @@ static void test_source_parse_config_reserved_name7(void **state) { const char *a = "PAGE_PREVIOUS: asd\r\n"; - sb_error_t *err = NULL; + blogc_error_t *err = NULL; sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(source); assert_non_null(err); - assert_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER); + assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER); assert_string_equal(err->msg, "'PAGE_PREVIOUS' variable is forbidden in source files. It will be set " "for you by the compiler."); - sb_error_free(err); + blogc_error_free(err); sb_trie_free(source); } @@ -415,15 +415,15 @@ static void test_source_parse_config_reserved_name8(void **state) { const char *a = "PAGE_CURRENT: asd\r\n"; - sb_error_t *err = NULL; + blogc_error_t *err = NULL; sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(source); assert_non_null(err); - assert_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER); + assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER); assert_string_equal(err->msg, "'PAGE_CURRENT' variable is forbidden in source files. It will be set " "for you by the compiler."); - sb_error_free(err); + blogc_error_free(err); sb_trie_free(source); } @@ -432,15 +432,15 @@ static void test_source_parse_config_reserved_name9(void **state) { const char *a = "PAGE_NEXT: asd\r\n"; - sb_error_t *err = NULL; + blogc_error_t *err = NULL; sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(source); assert_non_null(err); - assert_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER); + assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER); assert_string_equal(err->msg, "'PAGE_NEXT' variable is forbidden in source files. It will be set " "for you by the compiler."); - sb_error_free(err); + blogc_error_free(err); sb_trie_free(source); } @@ -449,15 +449,15 @@ static void test_source_parse_config_reserved_name10(void **state) { const char *a = "PAGE_LAST: asd\r\n"; - sb_error_t *err = NULL; + blogc_error_t *err = NULL; sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(source); assert_non_null(err); - assert_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER); + assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER); assert_string_equal(err->msg, "'PAGE_LAST' variable is forbidden in source files. It will be set " "for you by the compiler."); - sb_error_free(err); + blogc_error_free(err); sb_trie_free(source); } @@ -466,15 +466,15 @@ static void test_source_parse_config_reserved_name11(void **state) { const char *a = "BLOGC_VERSION: 1.0\r\n"; - sb_error_t *err = NULL; + blogc_error_t *err = NULL; sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(source); assert_non_null(err); - assert_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER); + assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER); assert_string_equal(err->msg, "'BLOGC_VERSION' variable is forbidden in source files. It will be set " "for you by the compiler."); - sb_error_free(err); + blogc_error_free(err); sb_trie_free(source); } @@ -483,15 +483,15 @@ static void test_source_parse_config_value_no_line_ending(void **state) { const char *a = "BOLA: asd"; - sb_error_t *err = NULL; + blogc_error_t *err = NULL; sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(source); assert_non_null(err); - assert_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER); + assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER); assert_string_equal(err->msg, "No line ending after the configuration value for 'BOLA'.\n" "Error occurred near line 1, position 10: BOLA: asd"); - sb_error_free(err); + blogc_error_free(err); sb_trie_free(source); } @@ -500,15 +500,15 @@ static void test_source_parse_invalid_separator(void **state) { const char *a = "BOLA: asd\n---#"; - sb_error_t *err = NULL; + blogc_error_t *err = NULL; sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(source); assert_non_null(err); - assert_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER); + assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER); assert_string_equal(err->msg, "Invalid content separator. Must be more than one '-' characters.\n" "Error occurred near line 2, position 4: ---#"); - sb_error_free(err); + blogc_error_free(err); sb_trie_free(source); } -- cgit v1.2.3-18-g5258 From 74b2ee22a6b60d53b1241e0c52284b288e561599 Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Wed, 27 Apr 2016 01:38:10 +0200 Subject: moved squareball back to blogc source tree. i don't have enough time to maintain a separated library at this point, and worry about soname bump, library stability, etc. all the code is trivial enough to be copied around, and all the utils are implemented as single file now, to make it easier to copy. --- tests/check_source_parser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/check_source_parser.c') diff --git a/tests/check_source_parser.c b/tests/check_source_parser.c index 0f891dd..477399c 100644 --- a/tests/check_source_parser.c +++ b/tests/check_source_parser.c @@ -173,7 +173,7 @@ test_source_parse_with_description(void **state) "# This is a test\n" "\n" "bola\n"; - sb_error_t *err = NULL; + blogc_error_t *err = NULL; sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); assert_null(err); assert_non_null(source); -- cgit v1.2.3-18-g5258 From 9699bf0ce6b34c0d05c509925f3367f2200caad5 Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Wed, 27 Apr 2016 02:34:19 +0200 Subject: remove squareball for good --- tests/check_source_parser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/check_source_parser.c') diff --git a/tests/check_source_parser.c b/tests/check_source_parser.c index 477399c..d94dc70 100644 --- a/tests/check_source_parser.c +++ b/tests/check_source_parser.c @@ -17,7 +17,7 @@ #include #include "../src/source-parser.h" #include "../src/error.h" -#include +#include "../src/utils.h" static void -- cgit v1.2.3-18-g5258