summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDodji Seketeli <dodji@gnome.org>2004-02-12 22:49:12 +0000
committerDodji Seketeli <dodji@src.gnome.org>2004-02-12 22:49:12 +0000
commit63f60598e030911846c399c3aab45e0cc8ee2993 (patch)
tree2b98e90197ccdd63766166ad88bd849915778c64 /tests
parente8f702b7cdd74a0be61123c6bf5fae5e0a0587b5 (diff)
downloadlibcroco-63f60598e030911846c399c3aab45e0cc8ee2993.tar.gz
added this new api entry point to parse comma separated list of property
2004-02-12 Dodji Seketeli <dodji@gnome.org> * src/cr-declaration.[ch]: (cr_declaration_parse_list_from_buf): added this new api entry point to parse comma separated list of property declarations. * src/cr-parser.c: (cr_parser_parse_expr): dont return an error when we encounter EOF immediately at the end of an expression. (cr_parser_get_tknzr): added this new api entry point to get the parser's underlying tokenizer. * src/cr-statement.h: fixed a comment here. * tests/test4-main.c: wrote a test for the new cr_declaration_parse_list_from_buf() function.
Diffstat (limited to 'tests')
-rw-r--r--tests/test4-main.c51
1 files changed, 49 insertions, 2 deletions
diff --git a/tests/test4-main.c b/tests/test4-main.c
index 3733ad5..5db1383 100644
--- a/tests/test4-main.c
+++ b/tests/test4-main.c
@@ -38,6 +38,9 @@ CRDocHandler * gv_test_handler = {0} ;
const guchar * gv_decl_buf =
"toto: tutu, tata" ;
+const guchar * gv_decl_list_buf =
+"toto: titi; prop1:val1 ; prop2:val2" ;
+
const guchar *gv_ruleset_buf =
"s1 > s2 {toto: tutu, tata} "
;
@@ -154,12 +157,13 @@ test_cr_declaration_parse (void)
decl = cr_declaration_parse_from_buf (NULL, gv_decl_buf,
CR_UTF_8) ;
+ if (!decl)
+ return CR_ERROR ;
tmp_str = cr_declaration_to_string (decl, 2) ;
if (decl)
{
cr_declaration_destroy (decl) ;
- return CR_OK ;
}
if (tmp_str)
@@ -168,7 +172,44 @@ test_cr_declaration_parse (void)
tmp_str = NULL ;
}
- return CR_ERROR ;
+ return CR_OK ;
+}
+
+static enum CRStatus
+test_cr_declaration_parse_list (void)
+{
+ GString *str = NULL ;
+ guchar *tmp_str = NULL ;
+ CRDeclaration *decl = NULL, *cur_decl = NULL ;
+
+ decl = cr_declaration_parse_list_from_buf (gv_decl_list_buf,
+ CR_UTF_8) ;
+ if (!decl)
+ return CR_ERROR ;
+ str = g_string_new (NULL) ;
+ for (cur_decl = decl ; cur_decl ; cur_decl = cur_decl->next)
+ {
+ tmp_str = cr_declaration_to_string (cur_decl, 2) ;
+ if (tmp_str)
+ {
+ g_string_append_printf (str, "%s;", tmp_str) ;
+ g_free (tmp_str) ;
+ tmp_str = NULL ;
+ }
+
+ }
+ if (decl)
+ {
+ cr_declaration_destroy (decl) ;
+ }
+
+ if (str)
+ {
+ g_string_free (str, TRUE) ;
+ str = NULL ;
+ }
+
+ return CR_OK ;
}
static enum CRStatus
@@ -363,6 +404,12 @@ main (int argc, char ** argv)
return 0 ;
}
+ status = test_cr_declaration_parse_list () ;
+ if (status != CR_OK)
+ {
+ g_print ("\nKO\n") ;
+ return 0 ;
+ }
status = test_cr_statement_ruleset_parse () ;
if (status != CR_OK)
{