aboutsummaryrefslogtreecommitdiffstats
path: root/tests/check_source_parser.c
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2016-07-03 04:49:09 +0200
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2016-07-03 04:49:09 +0200
commit3968529cad2baec099acff5fee47b5fe24624b03 (patch)
treef1140cb53fcb8b5359f29bb4bcff851124d56752 /tests/check_source_parser.c
parenta8ec8e389166adc1231930028bf845da5f9f40ef (diff)
downloadblogc-3968529cad2baec099acff5fee47b5fe24624b03.tar.gz
blogc-3968529cad2baec099acff5fee47b5fe24624b03.tar.bz2
blogc-3968529cad2baec099acff5fee47b5fe24624b03.zip
error: improved parser error reporting
now it shows a visual indicator '^' pointing to the position of the error, in the line after the error message. should be helpful for users writing templates, if any.
Diffstat (limited to 'tests/check_source_parser.c')
-rw-r--r--tests/check_source_parser.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/tests/check_source_parser.c b/tests/check_source_parser.c
index d94dc70..2dcaad6 100644
--- a/tests/check_source_parser.c
+++ b/tests/check_source_parser.c
@@ -220,7 +220,9 @@ test_source_parse_config_invalid_key(void **state)
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");
+ "Error occurred near line 1, position 1:\n"
+ "bola: guda\n"
+ "^");
blogc_error_free(err);
sb_trie_free(source);
}
@@ -236,7 +238,9 @@ test_source_parse_config_no_key(void **state)
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");
+ "Error occurred near line 1, position 4:\n"
+ "BOLa\n"
+ " ^");
blogc_error_free(err);
sb_trie_free(source);
}
@@ -252,7 +256,9 @@ test_source_parse_config_no_key2(void **state)
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");
+ "Error occurred near line 1, position 5:\n"
+ "BOLA\n"
+ " ^");
blogc_error_free(err);
sb_trie_free(source);
}
@@ -269,7 +275,9 @@ test_source_parse_config_no_value(void **state)
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:");
+ "Error occurred near line 1, position 6:\n"
+ "BOLA:\n"
+ " ^");
blogc_error_free(err);
sb_trie_free(source);
}
@@ -286,7 +294,9 @@ test_source_parse_config_no_value2(void **state)
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:");
+ "Error occurred near line 1, position 6:\n"
+ "BOLA:\n"
+ " ^");
blogc_error_free(err);
sb_trie_free(source);
}
@@ -490,7 +500,9 @@ test_source_parse_config_value_no_line_ending(void **state)
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");
+ "Error occurred near line 1, position 10:\n"
+ "BOLA: asd\n"
+ " ^");
blogc_error_free(err);
sb_trie_free(source);
}
@@ -507,7 +519,9 @@ test_source_parse_invalid_separator(void **state)
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: ---#");
+ "Error occurred near line 2, position 4:\n"
+ "---#\n"
+ " ^");
blogc_error_free(err);
sb_trie_free(source);
}