summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authordodji <dodji@seketeli.org>2003-06-15 18:00:31 +0000
committerDodji Seketeli <dodji@src.gnome.org>2003-06-15 18:00:31 +0000
commit359c7d2721532d0726e0882e178ab057bc046215 (patch)
treeeff106edb77b24b9018580f3627ab3e6332ba842 /tests
parent8dbe0817ddbf28c4f073447fad72b357f84d49d8 (diff)
downloadlibcroco-359c7d2721532d0726e0882e178ab057bc046215.tar.gz
updated this to test the new cr_statement_ruleset_parse_from_buf ()
2003-06-15 dodji <dodji@seketeli.org> * tests/test4-main.c: updated this to test the new cr_statement_ruleset_parse_from_buf () method. * src/parser/cr-statement.[ch]: Added a cr_statement_ruleset_parse_from_buf () method. This is based on the changes made in cr-parser.[ch]. * src/parser/cr-selector.[ch]: added a method cr_selector_parse_from_buf (). This is based on the changes made in cr-parser.[ch]. * src/parser/cr-parser.[ch]: Some rather important changes occured here ... revisited the way selectors and rulesets are parsed so that one could parse a buffer that contains only a ruleset. A visible implication of this is that cr_parser_parse_selector () and cr_parser_parse_ruleset () become public methods callable independantly. In the past, this was not possible. Only cr_parser_parse_stylesheet () was public. * src/parser/cr-om-parser.c: updated this to comply with the changes made in cr-doc-handler.[ch]. * src/parser/cr-doc-handler.[ch]: 1/ Created an explicitely private field of CRDocHandler to store parsing context, parsing result and any eventually needed private data structure. The privates fields are accessible through getters/setters though. 2/ made sure to increment the ref count of each instance of CRDocHandler at instanciation time. This may introduce some memleaks in the working code. I will fix them in next commits. * src/parser/cr-declaration.c: (cr_declaration_append2() ): modified this so that we can append declaration to a list of declarations that don't belong to a ruleset. Dodji.
Diffstat (limited to 'tests')
-rw-r--r--tests/test4-main.c40
1 files changed, 33 insertions, 7 deletions
diff --git a/tests/test4-main.c b/tests/test4-main.c
index 83ff06f..c6fbf0f 100644
--- a/tests/test4-main.c
+++ b/tests/test4-main.c
@@ -35,9 +35,13 @@
CRDocHandler * gv_test_handler = {0} ;
-const guchar * gv_decl=
+const guchar * gv_decl_buf =
"toto: tutu, tata" ;
+const guchar *gv_ruleset_buf =
+"s1 > s2 {toto: tutu, tata} "
+;
+
static void
display_help (char *prg_name) ;
@@ -123,7 +127,7 @@ test_cr_declaration_parse (void)
guchar * tmp_str = NULL ;
CRDeclaration * decl = NULL ;
- decl = cr_declaration_parse (NULL, gv_decl,
+ decl = cr_declaration_parse (NULL, gv_decl_buf,
CR_UTF_8) ;
tmp_str = cr_declaration_to_string (decl, 2) ;
@@ -142,6 +146,24 @@ test_cr_declaration_parse (void)
return CR_ERROR ;
}
+static enum CRStatus
+test_cr_statement_ruleset_parse (void)
+{
+ CRStatement *stmt = NULL ;
+
+ stmt = cr_statement_ruleset_parse_from_buf (gv_ruleset_buf,
+ CR_UTF_8) ;
+ g_return_val_if_fail (stmt, CR_ERROR) ;
+
+ if (stmt)
+ {
+ cr_statement_destroy (stmt) ;
+ stmt = NULL ;
+ }
+
+ return CR_OK ;
+}
+
/**
*The entry point of the testing routine.
*/
@@ -152,13 +174,19 @@ main (int argc, char ** argv)
enum CRStatus status = CR_OK ;
status = test_cr_declaration_parse () ;
+ if (status != CR_OK)
+ {
+ g_print ("\nKO\n") ;
+ return 0 ;
+ }
+ status = test_cr_statement_ruleset_parse () ;
if (status != CR_OK)
{
g_print ("\nKO\n") ;
return 0 ;
}
-
+
cr_test_utils_parse_cmd_line (argc, argv, &options) ;
if (options.display_help == TRUE)
@@ -179,13 +207,11 @@ main (int argc, char ** argv)
return 0 ;
}
- status = test_cr_parser_parse (options.files_list[0]) ;
-
-
+ status = test_cr_parser_parse (options.files_list[0]) ;
if (status != CR_OK)
{
g_print ("\nKO\n") ;
}
-
+
return 0 ;
}