diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2016-07-03 04:49:09 +0200 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2016-07-03 04:49:09 +0200 |
commit | 3968529cad2baec099acff5fee47b5fe24624b03 (patch) | |
tree | f1140cb53fcb8b5359f29bb4bcff851124d56752 /tests/check_error.c | |
parent | a8ec8e389166adc1231930028bf845da5f9f40ef (diff) | |
download | blogc-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_error.c')
-rw-r--r-- | tests/check_error.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/tests/check_error.c b/tests/check_error.c index 8818b00..a954095 100644 --- a/tests/check_error.c +++ b/tests/check_error.c @@ -49,21 +49,27 @@ test_error_parser(void **state) assert_non_null(error); assert_int_equal(error->type, 1); assert_string_equal(error->msg, - "asd 10\nError occurred near line 3, position 2: chunda"); + "asd 10\nError occurred near line 3, position 2:\n" + "chunda\n" + " ^"); blogc_error_free(error); a = "bola\nguda\nchunda"; error = blogc_error_parser(1, a, strlen(a), 11, "asd %d", 10); assert_non_null(error); assert_int_equal(error->type, 1); assert_string_equal(error->msg, - "asd 10\nError occurred near line 3, position 2: chunda"); + "asd 10\nError occurred near line 3, position 2:\n" + "chunda\n" + " ^"); blogc_error_free(error); a = "bola\nguda\nchunda"; error = blogc_error_parser(1, a, strlen(a), 0, "asd %d", 10); assert_non_null(error); assert_int_equal(error->type, 1); assert_string_equal(error->msg, - "asd 10\nError occurred near line 1, position 1: bola"); + "asd 10\nError occurred near line 1, position 1:\n" + "bola\n" + "^"); blogc_error_free(error); a = ""; error = blogc_error_parser(1, a, strlen(a), 0, "asd %d", 10); @@ -82,21 +88,27 @@ test_error_parser_crlf(void **state) assert_non_null(error); assert_int_equal(error->type, 1); assert_string_equal(error->msg, - "asd 10\nError occurred near line 3, position 2: chunda"); + "asd 10\nError occurred near line 3, position 2:\n" + "chunda\n" + " ^"); blogc_error_free(error); a = "bola\r\nguda\r\nchunda"; error = blogc_error_parser(1, a, strlen(a), 13, "asd %d", 10); assert_non_null(error); assert_int_equal(error->type, 1); assert_string_equal(error->msg, - "asd 10\nError occurred near line 3, position 2: chunda"); + "asd 10\nError occurred near line 3, position 2:\n" + "chunda\n" + " ^"); blogc_error_free(error); a = "bola\r\nguda\r\nchunda"; error = blogc_error_parser(1, a, strlen(a), 0, "asd %d", 10); assert_non_null(error); assert_int_equal(error->type, 1); assert_string_equal(error->msg, - "asd 10\nError occurred near line 1, position 1: bola"); + "asd 10\nError occurred near line 1, position 1:\n" + "bola\n" + "^"); blogc_error_free(error); } |