From 9fd0686e5a84f3c62e3a3ce4c11777e4f2050cb7 Mon Sep 17 00:00:00 2001 From: Dodji Date: Sat, 6 Mar 2004 22:49:56 +0000 Subject: when you reach an EOF, don't assume it's an error. Return the already 2004-03-06 Dodji * src/cr-tknzr.c: (cr_tknzr_parse_num): when you reach an EOF, don't assume it's an error. Return the already parsed part of the number. Next attempt of parsing will result in an * tests/test4-main.c: udpated this test the fix made above. CR_END_OF_INPUT_ERROR. --- tests/test4-main.c | 59 ++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 17 deletions(-) (limited to 'tests') diff --git a/tests/test4-main.c b/tests/test4-main.c index 4d0b68e..997e2ec 100644 --- a/tests/test4-main.c +++ b/tests/test4-main.c @@ -35,6 +35,8 @@ CRDocHandler * gv_test_handler = {0} ; +const guchar * gv_term_buf= "106" ; + const guchar * gv_decl_buf = "toto: tutu, tata" ; @@ -149,6 +151,32 @@ test_cr_parser_parse (guchar * a_file_uri) return status ; } + +static enum CRStatus +test_cr_term_parse_expression_from_buf (void) +{ + guchar * tmp_str = NULL ; + CRTerm * term = NULL ; + + term = cr_term_parse_expression_from_buf (gv_term_buf, + CR_UTF_8) ; + + if (!term) + return CR_ERROR ; + tmp_str = cr_term_to_string (term) ; + if (term) + { + cr_term_destroy (term) ; + term = NULL ; + } + if (tmp_str) + { + g_free (tmp_str) ; + tmp_str = NULL ; + } + return CR_OK ; +} + static enum CRStatus test_cr_declaration_parse (void) { @@ -397,66 +425,63 @@ main (int argc, char ** argv) struct Options options ; enum CRStatus status = CR_OK ; + status = test_cr_term_parse_expression_from_buf() ; + if (status != CR_OK) + { + g_print ("\ntest \"cr_term_parse_expression_from_buf failed\"") ; + } status = test_cr_declaration_parse () ; if (status != CR_OK) { - g_print ("\nKO\n") ; - return 0 ; + g_print ("\n test \"cr_declaration_parse() failed\"\n") ; } status = test_cr_declaration_parse_list () ; if (status != CR_OK) { - g_print ("\nKO\n") ; - return 0 ; + g_print ("\ntest cr_declaration_parse_list() failed\n") ; } status = test_cr_statement_ruleset_parse () ; if (status != CR_OK) { - g_print ("\nKO\n") ; - return 0 ; + g_print ("\ntest cr_statement_ruleset_parse() failed\n") ; } status = test_cr_statement_at_media_rule_parse () ; if (status != CR_OK) { - g_print ("\nKO\n") ; - return 0 ; + g_print ("\ntest cr_statement_at_media_rule_parse() failed\n") ; } test_cr_statement_at_page_rule_parse () ; if (status != CR_OK) { - g_print ("\nKO\n") ; + g_print ("\ntest cr_statement_at_page_rule_parse() failed\n") ; return 0 ; } status = test_cr_statement_at_charset_rule_parse () ; if (status != CR_OK) { - g_print ("\nKO\n") ; - return 0 ; + g_print ("\ntest cr_statement_at_charset_rule_parse() failed\n") ; } status = test_cr_statement_font_face_rule_parse_from_buf () ; if (status != CR_OK) { - g_print ("\nKO\n") ; - return 0 ; + g_print ("\ntest cr_statement_font_face_rule_parse_from_buf() failed\n") ; } test_cr_statement_at_import_rule_parse_from_buf () ; if (status != CR_OK) { - g_print ("\nKO\n") ; - return 0 ; + g_print ("\ntest cr_statement_at_import_rule() failed\n") ; } status = test_cr_statement_parse_from_buf () ; if (status != CR_OK) { - g_print ("\nKO\n") ; - return 0 ; + g_print ("\ntest cr_statement_parse_from_buf() failed\n") ; } cr_test_utils_parse_cmd_line (argc, argv, &options) ; -- cgit v1.2.1