From 3968529cad2baec099acff5fee47b5fe24624b03 Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Sun, 3 Jul 2016 04:49:09 +0200 Subject: 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. --- tests/check_error.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'tests/check_error.c') 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); } -- cgit v1.2.3-18-g5258