summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDodji Seketeli <dodji@src.gnome.org>2004-04-18 15:26:47 +0000
committerDodji Seketeli <dodji@src.gnome.org>2004-04-18 15:26:47 +0000
commit6d08258366de84957200071d2ec6aef2c027529c (patch)
tree41690fa2b005f166f6ee92e2915ef48f28d8b925 /tests
parent5d0671c2a41511e78b60f52ad25ac9748fbfd28a (diff)
downloadlibcroco-6d08258366de84957200071d2ec6aef2c027529c.tar.gz
Changes from arch/CVS synchronization
Diffstat (limited to 'tests')
-rw-r--r--tests/test-inputs/lots-of-comments.css198
-rw-r--r--tests/test-inputs/parsing-location.css25
-rw-r--r--tests/test-inputs/sel-child-class.css1
-rw-r--r--tests/test-inputs/sel-child-class.xml10
-rw-r--r--tests/test-inputs/several-media.css10
-rwxr-xr-xtests/test-lots-of-comments.sh6
-rw-r--r--tests/test-output-refs/test-lots-of-comments.out26
-rw-r--r--tests/test-output-refs/test-parsing-location.out198
-rw-r--r--tests/test-output-refs/test-sel-child-class.out4
-rw-r--r--tests/test-output-refs/test-several-media.out17
-rw-r--r--tests/test-output-refs/test4.2.css.out4
-rwxr-xr-xtests/test-parsing-location.sh6
-rwxr-xr-xtests/test-sel-child-class.sh6
-rwxr-xr-xtests/test-several-media.sh6
-rw-r--r--tests/test2-main.c141
-rw-r--r--tests/test3-main.c150
-rw-r--r--tests/test4-main.c4
17 files changed, 637 insertions, 175 deletions
diff --git a/tests/test-inputs/lots-of-comments.css b/tests/test-inputs/lots-of-comments.css
new file mode 100644
index 0000000..67955e6
--- /dev/null
+++ b/tests/test-inputs/lots-of-comments.css
@@ -0,0 +1,198 @@
+
+
+@charset "utf8";
+
+/********************************************
+ * Parsing location information of the @charset rule
+ ********************************************/
+ /*@charset*/
+ /*line:1 column:1 byte offset:0 */
+ /*utf8*/
+ /*line:1 column:10 byte offset:9 */
+
+@import url("http://pouet.com") screen, paper, aural;
+
+/*****************************************************
+ *Parsing location inforamtion for the @import rule
+ ******************************************************/
+
+ /*@import*/
+ /*line:3 column:1 byte offset:19 */
+
+ /*http://pouet.com*/
+ /*line:3 column:13 byte offset:31 */
+
+ /*screen*/
+ /*line:3 column:33 byte offset:51 */
+
+ /*paper*/
+ /*line:3 column:41 byte offset:59 */
+
+ /*aural*/
+ /*line:3 column:48 byte offset:66 */
+
+@page coin :pseudo-page
+
+ /*@page*/
+ /*line:5 column:1 byte offset:75 */
+ /*coin*/
+ /*line:5 column:7 byte offset:81 */
+ /*pseudo-page*/
+ /*line:5 column:13 byte offset:87 */
+
+{
+
+
+page-prop0 : page-val0;
+
+
+/************************************************
+ *Parsing location information of the property
+ ************************************************/
+ /*page-prop0*/
+ /*line:6 column:7 byte offset:107 */
+ /*page-val0*/
+ /*line:6 column:19 byte offset:119 */
+
+
+page-prop1 : page-val1;
+
+
+/************************************************
+ *Parsing location information of the property
+ ************************************************/
+ /*page-prop1*/
+ /*line:7 column:7 byte offset:137 */
+ /*page-val1*/
+ /*line:7 column:19 byte offset:149 */
+}
+@media paper, aural
+ /*@media*/
+ /*line:10 column:1 byte offset:164 */
+ /*paper*/
+ /*line:10 column:8 byte offset:171 */
+ /*aural*/
+ /*line:10 column:15 byte offset:178 */
+
+{
+x {
+/************************************************
+ *Parsing location information of the selector
+ ************************************************/
+/*x*/
+/*line:11 column:5 byte offset:190 */
+ /*x*/
+ /*line:11 column:5 byte offset:190 */
+
+
+foo : fooval;
+
+
+/************************************************
+ *Parsing location information of the property
+ ************************************************/
+ /*foo*/
+ /*line:12 column:7 byte offset:200 */
+ /*fooval*/
+ /*line:12 column:12 byte offset:205 */
+
+
+bar : barval;
+
+
+/************************************************
+ *Parsing location information of the property
+ ************************************************/
+ /*bar*/
+ /*line:13 column:7 byte offset:220 */
+ /*barval*/
+ /*line:13 column:12 byte offset:225 */
+ }
+
+}
+@font-face {
+/******************************************************
+ Parsing location information for the @font-face rule
+ ******************************************************/
+
+ /*@font-face*/
+ /*line:17 column:1 byte offset:243 */
+
+
+font-prop1 : font1;
+
+
+/************************************************
+ *Parsing location information of the property
+ ************************************************/
+ /*font-prop1*/
+ /*line:18 column:2 byte offset:257 */
+ /*font1*/
+ /*line:18 column:14 byte offset:269 */
+
+
+font-prop2 : font2;
+
+
+/************************************************
+ *Parsing location information of the property
+ ************************************************/
+ /*font-prop2*/
+ /*line:19 column:2 byte offset:278 */
+ /*font2*/
+ /*line:19 column:14 byte offset:290 */
+}
+x>y[attr="val"].class#tatati z+toto {
+/************************************************
+ *Parsing location information of the selector
+ ************************************************/
+/*x*/
+/*line:21 column:1 byte offset:300 */
+ /*x*/
+ /*line:21 column:1 byte offset:300 */
+/*y[attr="val"].class#tatati*/
+/*line:21 column:5 byte offset:304 */
+ /*y*/
+ /*line:21 column:5 byte offset:304 */
+
+ /*[attr="val"]*/
+ /*line:21 column:6 byte offset:305 */
+
+ /*.class*/
+ /*line:21 column:17 byte offset:316 */
+
+ /*#tatati*/
+ /*line:21 column:22 byte offset:321 */
+/*z*/
+/*line:21 column:30 byte offset:329 */
+ /*z*/
+ /*line:21 column:30 byte offset:329 */
+/*toto*/
+/*line:21 column:34 byte offset:333 */
+ /*toto*/
+ /*line:21 column:34 byte offset:333 */
+
+
+prop1 : function(a);
+
+
+/************************************************
+ *Parsing location information of the property
+ ************************************************/
+ /*prop1*/
+ /*line:22 column:2 byte offset:340 */
+ /*function(a)*/
+ /*line:22 column:9 byte offset:347 */
+
+
+prop2 : val2;
+
+
+/************************************************
+ *Parsing location information of the property
+ ************************************************/
+ /*prop2*/
+ /*line:23 column:2 byte offset:362 */
+ /*val2*/
+ /*line:23 column:9 byte offset:369 */
+ }
diff --git a/tests/test-inputs/parsing-location.css b/tests/test-inputs/parsing-location.css
new file mode 100644
index 0000000..44f1e28
--- /dev/null
+++ b/tests/test-inputs/parsing-location.css
@@ -0,0 +1,25 @@
+@charset "utf8" ;
+
+@import url("http://pouet.com") screen, paper, aural ;
+
+@page coin :pseudo-page {
+ page-prop0: page-val0 ;
+ page-prop1: page-val1 ;
+}
+
+@media paper, aural {
+ x {
+ foo: fooval ;
+ bar: barval ;
+ }
+}
+
+@font-face {
+ font-prop1: font1 ;
+ font-prop2: font2 ;
+}
+x > y[attr=val].class#tatati z + toto{
+ prop1: function(a) ;
+ prop2: val2
+}
+
diff --git a/tests/test-inputs/sel-child-class.css b/tests/test-inputs/sel-child-class.css
new file mode 100644
index 0000000..a6ea36b
--- /dev/null
+++ b/tests/test-inputs/sel-child-class.css
@@ -0,0 +1 @@
+body > div p.process { color: aqua; }
diff --git a/tests/test-inputs/sel-child-class.xml b/tests/test-inputs/sel-child-class.xml
new file mode 100644
index 0000000..ee5e23d
--- /dev/null
+++ b/tests/test-inputs/sel-child-class.xml
@@ -0,0 +1,10 @@
+<test>
+ <body>
+ <div>
+ <div>
+ <p class="process">This should be aqua</p>
+ </div>
+ </div>
+ </body>
+</test>
+
diff --git a/tests/test-inputs/several-media.css b/tests/test-inputs/several-media.css
new file mode 100644
index 0000000..79dc336
--- /dev/null
+++ b/tests/test-inputs/several-media.css
@@ -0,0 +1,10 @@
+@media screen {
+a:link { text-decoration: none; }
+div { width: 50%; }
+}
+
+@media print {
+a { color: red; }
+div { width: 57%; }
+}
+
diff --git a/tests/test-lots-of-comments.sh b/tests/test-lots-of-comments.sh
new file mode 100755
index 0000000..c47a6c2
--- /dev/null
+++ b/tests/test-lots-of-comments.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+HERE_DIR=`dirname $0`
+. $HERE_DIR/global-vars.sh
+
+$CSSLINT $TEST_INPUTS_DIR/lots-of-comments.css
diff --git a/tests/test-output-refs/test-lots-of-comments.out b/tests/test-output-refs/test-lots-of-comments.out
new file mode 100644
index 0000000..59b08ef
--- /dev/null
+++ b/tests/test-output-refs/test-lots-of-comments.out
@@ -0,0 +1,26 @@
+@charset "utf8" ;
+
+@import url("http://pouet.com")screen, paper, aural ;
+
+@page coin :pseudo-page {
+ page-prop0 : page-val0;
+ page-prop1 : page-val1
+}
+
+
+@media paper, aural {
+ x {
+ foo : fooval;
+ bar : barval
+ }
+}
+
+@font-face {
+ font-prop1 : font1;
+ font-prop2 : font2
+}
+
+x>y[attr="val"].class#tatati z+toto {
+ prop1 : function(a);
+ prop2 : val2
+}
diff --git a/tests/test-output-refs/test-parsing-location.out b/tests/test-output-refs/test-parsing-location.out
new file mode 100644
index 0000000..67955e6
--- /dev/null
+++ b/tests/test-output-refs/test-parsing-location.out
@@ -0,0 +1,198 @@
+
+
+@charset "utf8";
+
+/********************************************
+ * Parsing location information of the @charset rule
+ ********************************************/
+ /*@charset*/
+ /*line:1 column:1 byte offset:0 */
+ /*utf8*/
+ /*line:1 column:10 byte offset:9 */
+
+@import url("http://pouet.com") screen, paper, aural;
+
+/*****************************************************
+ *Parsing location inforamtion for the @import rule
+ ******************************************************/
+
+ /*@import*/
+ /*line:3 column:1 byte offset:19 */
+
+ /*http://pouet.com*/
+ /*line:3 column:13 byte offset:31 */
+
+ /*screen*/
+ /*line:3 column:33 byte offset:51 */
+
+ /*paper*/
+ /*line:3 column:41 byte offset:59 */
+
+ /*aural*/
+ /*line:3 column:48 byte offset:66 */
+
+@page coin :pseudo-page
+
+ /*@page*/
+ /*line:5 column:1 byte offset:75 */
+ /*coin*/
+ /*line:5 column:7 byte offset:81 */
+ /*pseudo-page*/
+ /*line:5 column:13 byte offset:87 */
+
+{
+
+
+page-prop0 : page-val0;
+
+
+/************************************************
+ *Parsing location information of the property
+ ************************************************/
+ /*page-prop0*/
+ /*line:6 column:7 byte offset:107 */
+ /*page-val0*/
+ /*line:6 column:19 byte offset:119 */
+
+
+page-prop1 : page-val1;
+
+
+/************************************************
+ *Parsing location information of the property
+ ************************************************/
+ /*page-prop1*/
+ /*line:7 column:7 byte offset:137 */
+ /*page-val1*/
+ /*line:7 column:19 byte offset:149 */
+}
+@media paper, aural
+ /*@media*/
+ /*line:10 column:1 byte offset:164 */
+ /*paper*/
+ /*line:10 column:8 byte offset:171 */
+ /*aural*/
+ /*line:10 column:15 byte offset:178 */
+
+{
+x {
+/************************************************
+ *Parsing location information of the selector
+ ************************************************/
+/*x*/
+/*line:11 column:5 byte offset:190 */
+ /*x*/
+ /*line:11 column:5 byte offset:190 */
+
+
+foo : fooval;
+
+
+/************************************************
+ *Parsing location information of the property
+ ************************************************/
+ /*foo*/
+ /*line:12 column:7 byte offset:200 */
+ /*fooval*/
+ /*line:12 column:12 byte offset:205 */
+
+
+bar : barval;
+
+
+/************************************************
+ *Parsing location information of the property
+ ************************************************/
+ /*bar*/
+ /*line:13 column:7 byte offset:220 */
+ /*barval*/
+ /*line:13 column:12 byte offset:225 */
+ }
+
+}
+@font-face {
+/******************************************************
+ Parsing location information for the @font-face rule
+ ******************************************************/
+
+ /*@font-face*/
+ /*line:17 column:1 byte offset:243 */
+
+
+font-prop1 : font1;
+
+
+/************************************************
+ *Parsing location information of the property
+ ************************************************/
+ /*font-prop1*/
+ /*line:18 column:2 byte offset:257 */
+ /*font1*/
+ /*line:18 column:14 byte offset:269 */
+
+
+font-prop2 : font2;
+
+
+/************************************************
+ *Parsing location information of the property
+ ************************************************/
+ /*font-prop2*/
+ /*line:19 column:2 byte offset:278 */
+ /*font2*/
+ /*line:19 column:14 byte offset:290 */
+}
+x>y[attr="val"].class#tatati z+toto {
+/************************************************
+ *Parsing location information of the selector
+ ************************************************/
+/*x*/
+/*line:21 column:1 byte offset:300 */
+ /*x*/
+ /*line:21 column:1 byte offset:300 */
+/*y[attr="val"].class#tatati*/
+/*line:21 column:5 byte offset:304 */
+ /*y*/
+ /*line:21 column:5 byte offset:304 */
+
+ /*[attr="val"]*/
+ /*line:21 column:6 byte offset:305 */
+
+ /*.class*/
+ /*line:21 column:17 byte offset:316 */
+
+ /*#tatati*/
+ /*line:21 column:22 byte offset:321 */
+/*z*/
+/*line:21 column:30 byte offset:329 */
+ /*z*/
+ /*line:21 column:30 byte offset:329 */
+/*toto*/
+/*line:21 column:34 byte offset:333 */
+ /*toto*/
+ /*line:21 column:34 byte offset:333 */
+
+
+prop1 : function(a);
+
+
+/************************************************
+ *Parsing location information of the property
+ ************************************************/
+ /*prop1*/
+ /*line:22 column:2 byte offset:340 */
+ /*function(a)*/
+ /*line:22 column:9 byte offset:347 */
+
+
+prop2 : val2;
+
+
+/************************************************
+ *Parsing location information of the property
+ ************************************************/
+ /*prop2*/
+ /*line:23 column:2 byte offset:362 */
+ /*val2*/
+ /*line:23 column:9 byte offset:369 */
+ }
diff --git a/tests/test-output-refs/test-sel-child-class.out b/tests/test-output-refs/test-sel-child-class.out
new file mode 100644
index 0000000..aadd508
--- /dev/null
+++ b/tests/test-output-refs/test-sel-child-class.out
@@ -0,0 +1,4 @@
+Properties of xml element p are:
+ color : aqua
+=====================
+
diff --git a/tests/test-output-refs/test-several-media.out b/tests/test-output-refs/test-several-media.out
new file mode 100644
index 0000000..4b3cbdd
--- /dev/null
+++ b/tests/test-output-refs/test-several-media.out
@@ -0,0 +1,17 @@
+@media screen {
+ a:link {
+ text-decoration : none
+ }
+ div {
+ width : 50%
+ }
+}
+
+@media print {
+ a {
+ color : red
+ }
+ div {
+ width : 57%
+ }
+}
diff --git a/tests/test-output-refs/test4.2.css.out b/tests/test-output-refs/test4.2.css.out
index ae12244..64fe087 100644
--- a/tests/test-output-refs/test4.2.css.out
+++ b/tests/test-output-refs/test4.2.css.out
@@ -17,4 +17,8 @@
H1 {
font-family : "Robson Celtic", serif
}
+ P {
+ background : black;
+ foreground : white
+ }
} \ No newline at end of file
diff --git a/tests/test-parsing-location.sh b/tests/test-parsing-location.sh
new file mode 100755
index 0000000..70fa409
--- /dev/null
+++ b/tests/test-parsing-location.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+HERE_DIR=`dirname $0`
+. $HERE_DIR/global-vars.sh
+
+$CSSLINT --dump-location $TEST_INPUTS_DIR/parsing-location.css
diff --git a/tests/test-sel-child-class.sh b/tests/test-sel-child-class.sh
new file mode 100755
index 0000000..cb1e4d3
--- /dev/null
+++ b/tests/test-sel-child-class.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+HERE_DIR=`dirname $0`
+. $HERE_DIR/global-vars.sh
+
+$CSSLINT -e --user-sheet $TEST_INPUTS_DIR/sel-child-class.css --xml $TEST_INPUTS_DIR/sel-child-class.xml --xpath /test/body/div/div/p
diff --git a/tests/test-several-media.sh b/tests/test-several-media.sh
new file mode 100755
index 0000000..394d43a
--- /dev/null
+++ b/tests/test-several-media.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+HERE_DIR=`dirname $0`
+. $HERE_DIR/global-vars.sh
+
+$CSSLINT $TEST_INPUTS_DIR/several-media.css
diff --git a/tests/test2-main.c b/tests/test2-main.c
index fc991cd..b4c43be 100644
--- a/tests/test2-main.c
+++ b/tests/test2-main.c
@@ -110,10 +110,12 @@ test_end_document (CRDocHandler * a_handler)
static void
test_import_style (CRDocHandler * a_handler,
- GList * a_media_list, GString * a_uri,
- GString * a_uri_default_ns)
+ GList * a_media_list,
+ CRString * a_uri,
+ CRString * a_uri_default_ns,
+ CRParsingLocation *a_location)
{
- g_return_if_fail (a_handler);
+ g_return_if_fail (a_handler) ;
fprintf (stdout, "****************\n");
fprintf (stdout, "import_style\n");
@@ -128,8 +130,8 @@ test_import_style (CRDocHandler * a_handler,
if (cur->data) {
guchar *str =
g_strndup
- (((GString *) cur->data)->str,
- ((GString *) cur->data)->len);
+ (((CRString *) cur->data)->stryng->str,
+ ((CRString *) cur->data)->stryng->len);
if (str) {
fprintf (stdout, str);
@@ -143,10 +145,9 @@ test_import_style (CRDocHandler * a_handler,
fprintf (stdout, "\ndefault namespace:\n");
fprintf (stdout, "--------------------\n");
- if (a_uri_default_ns && a_uri_default_ns->str) {
- guchar *str = g_strndup (a_uri_default_ns->str,
- a_uri_default_ns->len);
-
+ if (a_uri_default_ns) {
+ guchar *str = cr_string_dup2
+ (a_uri_default_ns) ;
if (str) {
fprintf (stdout, str);
fprintf (stdout, "\n");
@@ -155,37 +156,35 @@ test_import_style (CRDocHandler * a_handler,
}
}
}
-
fprintf (stdout, "******************\n\n");
a_uri = NULL; /*keep compiler happy */
}
static void
test_namespace_declaration (CRDocHandler * a_handler,
- GString * a_prefix, GString * a_uri)
+ CRString * a_prefix,
+ CRString * a_uri,
+ CRParsingLocation *a_location)
{
g_return_if_fail (a_handler);
fprintf (stdout, "***************\n");
fprintf (stdout, "namespace_declaration:\n");
- if (a_prefix && a_prefix->str) {
+ if (a_prefix) {
guchar *prefix = NULL;
- prefix = g_strndup (a_prefix->str, a_prefix->len);
-
+ prefix = cr_string_dup2 (a_prefix) ;
if (prefix) {
fprintf (stdout, "prefix: %s\n", prefix);
g_free (prefix);
prefix = NULL;
}
}
-
- if (a_uri && a_uri->str) {
+ if (a_uri) {
guchar *uri = NULL;
- uri = g_strndup (a_uri->str, a_uri->len);
-
+ uri = cr_string_dup2 (a_uri) ;
if (uri) {
fprintf (stdout, "uri: %s\n", uri);
g_free (uri);
@@ -199,33 +198,32 @@ test_namespace_declaration (CRDocHandler * a_handler,
}
static void
-test_comment (CRDocHandler * a_handler, GString * a_comment)
+test_comment (CRDocHandler * a_handler,
+ CRString * a_comment)
{
g_return_if_fail (a_handler);
fprintf (stdout, "***************\n");
fprintf (stdout, "comment:\n");
-
- if (a_comment && a_comment->str) {
+ if (a_comment) {
guchar *comment = NULL;
- comment = g_strndup (a_comment->str, a_comment->len);
+ comment = cr_string_dup2 (a_comment);
if (comment) {
fprintf (stdout, "\n/*----------------------\n");
fprintf (stdout, "%s\n", comment);
fprintf (stdout, "-------------------------*/\n");
-
g_free (comment);
comment = NULL;
}
}
-
fprintf (stdout, "***************\n\n");
}
static void
-test_start_selector (CRDocHandler * a_handler, CRSelector * a_selector_list)
+test_start_selector (CRDocHandler * a_handler,
+ CRSelector * a_selector_list)
{
g_return_if_fail (a_handler);
@@ -241,7 +239,8 @@ test_start_selector (CRDocHandler * a_handler, CRSelector * a_selector_list)
}
static void
-test_end_selector (CRDocHandler * a_handler, CRSelector * a_selector_list)
+test_end_selector (CRDocHandler * a_handler,
+ CRSelector * a_selector_list)
{
g_return_if_fail (a_handler);
@@ -257,39 +256,42 @@ test_end_selector (CRDocHandler * a_handler, CRSelector * a_selector_list)
}
static void
-test_property (CRDocHandler * a_handler, GString * a_name,
- CRTerm * a_expr, gboolean a_important)
+test_property (CRDocHandler * a_handler,
+ CRString * a_name,
+ CRTerm * a_expr,
+ gboolean a_important)
{
g_return_if_fail (a_handler);
fprintf (stdout, "***************\n");
fprintf (stdout, "property\n");
- if (a_name && a_name->str) {
- guchar *name = g_strndup (a_name->str, a_name->len);
+ if (a_name
+ && a_name->stryng
+ && a_name->stryng->str) {
+ guchar *name = g_strndup
+ (a_name->stryng->str,
+ a_name->stryng->len);
if (name) {
fprintf (stdout, name);
}
-
if (a_expr) {
fprintf (stdout, ": ");
cr_term_dump (a_expr, stdout);
}
-
if (name) {
g_free (name);
name = NULL;
}
-
fprintf (stdout, "\n");
}
-
fprintf (stdout, "***************\n\n");
}
static void
-test_start_font_face (CRDocHandler * a_handler)
+test_start_font_face (CRDocHandler * a_handler,
+ CRParsingLocation *a_location)
{
g_return_if_fail (a_handler);
@@ -310,7 +312,9 @@ test_end_font_face (CRDocHandler * a_handler)
}
static void
-test_start_media (CRDocHandler * a_handler, GList * a_media_list)
+test_start_media (CRDocHandler * a_handler,
+ GList * a_media_list,
+ CRParsingLocation *a_location)
{
g_return_if_fail (a_handler);
@@ -324,27 +328,23 @@ test_start_media (CRDocHandler * a_handler, GList * a_media_list)
for (cur = a_media_list; cur; cur = cur->next) {
if (cur->data == NULL)
continue;
-
- medium = g_strndup (((GString *) cur->data)->str,
- ((GString *) cur->data)->len);
-
+ medium = cr_string_dup2
+ ((CRString *) cur->data);
if (medium == NULL)
continue;
-
fprintf (stdout, "medium: %s\n", medium);
-
if (medium) {
g_free (medium);
medium = NULL;
}
}
}
-
fprintf (stdout, "***************\n\n");
}
static void
-test_end_media (CRDocHandler * a_handler, GList * a_media_list)
+test_end_media (CRDocHandler * a_handler,
+ GList * a_media_list)
{
g_return_if_fail (a_handler);
@@ -359,14 +359,11 @@ test_end_media (CRDocHandler * a_handler, GList * a_media_list)
if (cur->data == NULL)
continue;
- medium = g_strndup (((GString *) cur->data)->str,
- ((GString *) cur->data)->len);
-
+ medium = g_strndup (((CRString *) cur->data)->stryng->str,
+ ((CRString *) cur->data)->stryng->len);
if (medium == NULL)
continue;
-
fprintf (stdout, "medium: %s\n", medium);
-
if (medium) {
g_free (medium);
medium = NULL;
@@ -379,7 +376,9 @@ test_end_media (CRDocHandler * a_handler, GList * a_media_list)
static void
test_start_page (CRDocHandler * a_handler,
- GString * a_name, GString * a_pseudo_page)
+ CRString * a_name,
+ CRString * a_pseudo_page,
+ CRParsingLocation *a_location)
{
guchar *name = NULL,
*pseudo_page = NULL;
@@ -389,30 +388,23 @@ test_start_page (CRDocHandler * a_handler,
fprintf (stdout, "***************\n");
fprintf (stdout, "start_page\n");
- if (a_name && a_name->str) {
- name = g_strndup (a_name->str, a_name->len);
+ if (a_name) {
+ name = cr_string_dup2 (a_name) ;
}
-
- if (a_pseudo_page && a_pseudo_page->str) {
- pseudo_page = g_strndup (a_pseudo_page->str,
- a_pseudo_page->len);
+ if (a_pseudo_page) {
+ pseudo_page = cr_string_dup2 (a_pseudo_page);
}
-
if (name) {
fprintf (stdout, "%s", name);
}
-
if (pseudo_page) {
fprintf (stdout, ": %s\n", pseudo_page);
}
-
fprintf (stdout, "***************\n\n");
-
if (name) {
g_free (name);
name = NULL;
}
-
if (pseudo_page) {
g_free (pseudo_page);
pseudo_page = NULL;
@@ -421,7 +413,8 @@ test_start_page (CRDocHandler * a_handler,
static void
test_end_page (CRDocHandler * a_handler,
- GString * a_name, GString * a_pseudo_page)
+ CRString * a_name,
+ CRString * a_pseudo_page)
{
guchar *name = NULL,
*pseudo_page = NULL;
@@ -431,31 +424,24 @@ test_end_page (CRDocHandler * a_handler,
fprintf (stdout, "***************\n");
fprintf (stdout, "end_page\n");
- if (a_name && a_name->str) {
- name = g_strndup (a_name->str, a_name->len);
+ if (a_name) {
+ name = cr_string_dup2 (a_name) ;
}
-
- if (a_pseudo_page && a_pseudo_page->str) {
- pseudo_page = g_strndup (a_pseudo_page->str,
- a_pseudo_page->len);
+ if (a_pseudo_page) {
+ pseudo_page = cr_string_dup2 (a_pseudo_page) ;
}
-
if (name) {
fprintf (stdout, "%s", name);
}
-
if (pseudo_page) {
fprintf (stdout, ": %s\n", pseudo_page);
}
-
fprintf (stdout, "***************\n\n");
-
if (name) {
g_free (name);
name = NULL;
}
-
if (pseudo_page) {
g_free (pseudo_page);
pseudo_page = NULL;
@@ -463,7 +449,8 @@ test_end_page (CRDocHandler * a_handler,
}
static void
-test_ignorable_at_rule (CRDocHandler * a_handler, GString * a_name)
+test_ignorable_at_rule (CRDocHandler * a_handler,
+ CRString * a_name)
{
guchar *name = NULL;
@@ -472,14 +459,12 @@ test_ignorable_at_rule (CRDocHandler * a_handler, GString * a_name)
fprintf (stdout, "*********************\n");
fprintf (stdout, "ignorable_at_rule\n");
- if (a_name && a_name->str) {
- name = g_strndup (a_name->str, a_name->len);
+ if (a_name) {
+ name = cr_string_dup2 (a_name);
}
-
if (name) {
fprintf (stdout, "%s\n", name);
}
-
fprintf (stdout, "*********************\n\n");
}
diff --git a/tests/test3-main.c b/tests/test3-main.c
index e312b3b..f2c69c9 100644
--- a/tests/test3-main.c
+++ b/tests/test3-main.c
@@ -3,8 +3,6 @@
/*
* This file is part of The Croco Library
*
- * Copyright (C) 2002-2003 Dodji Seketeli <dodji@seketeli.org>
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2.1 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
@@ -18,10 +16,9 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
- */
-
-/*
- *$Id$
+ *
+ * Author: Dodji Seketeli
+ * See COPYRIGHTS file for copyright information.
*/
#include <stdio.h>
@@ -36,14 +33,11 @@
CRDocHandler *gv_test_handler = { 0 };
-static void
- display_help (char *prg_name);
+static void display_help (char *prg_name);
-static void
- display_about (char *prg_name);
+static void display_about (char *prg_name);
-static enum CRStatus
- test_cr_parser_parse (guchar * a_file_uri);
+static enum CRStatus test_cr_parser_parse (guchar * a_file_uri);
/**
*Displays the usage of the test
@@ -109,8 +103,9 @@ test_end_document (CRDocHandler * a_handler)
static void
test_import_style (CRDocHandler * a_handler,
- GList * a_media_list, GString * a_uri,
- GString * a_uri_default_ns)
+ GList * a_media_list, CRString * a_uri,
+ CRString * a_uri_default_ns,
+ CRParsingLocation *a_location)
{
g_return_if_fail (a_handler);
@@ -126,10 +121,7 @@ test_import_style (CRDocHandler * a_handler,
for (cur = a_media_list; cur; cur = cur->next) {
if (cur->data) {
guchar *str =
- g_strndup
- (((GString *) cur->data)->str,
- ((GString *) cur->data)->len);
-
+ cr_string_dup2 ((CRString *) cur->data);
if (str) {
fprintf (stdout, str);
fprintf (stdout, "\n");
@@ -138,14 +130,11 @@ test_import_style (CRDocHandler * a_handler,
}
}
}
-
fprintf (stdout, "\ndefault namespace:\n");
fprintf (stdout, "--------------------\n");
- if (a_uri_default_ns && a_uri_default_ns->str) {
- guchar *str = g_strndup (a_uri_default_ns->str,
- a_uri_default_ns->len);
-
+ if (a_uri_default_ns) {
+ guchar *str = cr_string_dup2 (a_uri_default_ns) ;
if (str) {
fprintf (stdout, str);
fprintf (stdout, "\n");
@@ -154,25 +143,25 @@ test_import_style (CRDocHandler * a_handler,
}
}
}
-
fprintf (stdout, "******************\n\n");
a_uri = NULL; /*keep compiler happy */
}
static void
test_namespace_declaration (CRDocHandler * a_handler,
- GString * a_prefix, GString * a_uri)
+ CRString * a_prefix,
+ CRString * a_uri,
+ CRParsingLocation *a_location)
{
g_return_if_fail (a_handler);
fprintf (stdout, "***************\n");
fprintf (stdout, "namespace_declaration:\n");
- if (a_prefix && a_prefix->str) {
+ if (a_prefix) {
guchar *prefix = NULL;
- prefix = g_strndup (a_prefix->str, a_prefix->len);
-
+ prefix = cr_string_dup2 (a_prefix);
if (prefix) {
fprintf (stdout, "prefix: %s\n", prefix);
g_free (prefix);
@@ -180,11 +169,9 @@ test_namespace_declaration (CRDocHandler * a_handler,
}
}
- if (a_uri && a_uri->str) {
+ if (a_uri) {
guchar *uri = NULL;
-
- uri = g_strndup (a_uri->str, a_uri->len);
-
+ uri = cr_string_dup2 (a_uri) ;
if (uri) {
fprintf (stdout, "uri: %s\n", uri);
g_free (uri);
@@ -198,33 +185,33 @@ test_namespace_declaration (CRDocHandler * a_handler,
}
static void
-test_comment (CRDocHandler * a_handler, GString * a_comment)
+test_comment (CRDocHandler * a_handler,
+ CRString * a_comment)
{
g_return_if_fail (a_handler);
fprintf (stdout, "***************\n");
fprintf (stdout, "comment:\n");
- if (a_comment && a_comment->str) {
+ if (a_comment) {
guchar *comment = NULL;
- comment = g_strndup (a_comment->str, a_comment->len);
+ comment = cr_string_dup2 (a_comment);
if (comment) {
fprintf (stdout, "\n/*----------------------\n");
fprintf (stdout, "%s\n", comment);
fprintf (stdout, "-------------------------*/\n");
-
g_free (comment);
comment = NULL;
}
}
-
fprintf (stdout, "***************\n\n");
}
static void
-test_start_selector (CRDocHandler * a_handler, CRSelector * a_selector_list)
+test_start_selector (CRDocHandler * a_handler,
+ CRSelector * a_selector_list)
{
g_return_if_fail (a_handler);
@@ -240,7 +227,8 @@ test_start_selector (CRDocHandler * a_handler, CRSelector * a_selector_list)
}
static void
-test_end_selector (CRDocHandler * a_handler, CRSelector * a_selector_list)
+test_end_selector (CRDocHandler * a_handler,
+ CRSelector * a_selector_list)
{
g_return_if_fail (a_handler);
@@ -256,7 +244,7 @@ test_end_selector (CRDocHandler * a_handler, CRSelector * a_selector_list)
}
static void
-test_property (CRDocHandler * a_handler, GString * a_name,
+test_property (CRDocHandler * a_handler, CRString * a_name,
CRTerm * a_expr, gboolean a_important)
{
g_return_if_fail (a_handler);
@@ -264,31 +252,27 @@ test_property (CRDocHandler * a_handler, GString * a_name,
fprintf (stdout, "***************\n");
fprintf (stdout, "property\n");
- if (a_name && a_name->str) {
- guchar *name = g_strndup (a_name->str, a_name->len);
-
+ if (a_name) {
+ guchar *name = cr_string_dup2 (a_name);
if (name) {
fprintf (stdout, name);
}
-
if (a_expr) {
fprintf (stdout, ": ");
cr_term_dump (a_expr, stdout);
}
-
if (name) {
g_free (name);
name = NULL;
}
-
fprintf (stdout, "\n");
}
-
fprintf (stdout, "***************\n\n");
}
static void
-test_start_font_face (CRDocHandler * a_handler)
+test_start_font_face (CRDocHandler * a_handler,
+ CRParsingLocation *a_location)
{
g_return_if_fail (a_handler);
@@ -309,7 +293,9 @@ test_end_font_face (CRDocHandler * a_handler)
}
static void
-test_start_media (CRDocHandler * a_handler, GList * a_media_list)
+test_start_media (CRDocHandler * a_handler,
+ GList * a_media_list,
+ CRParsingLocation *a_location)
{
g_return_if_fail (a_handler);
@@ -323,27 +309,22 @@ test_start_media (CRDocHandler * a_handler, GList * a_media_list)
for (cur = a_media_list; cur; cur = cur->next) {
if (cur->data == NULL)
continue;
-
- medium = g_strndup (((GString *) cur->data)->str,
- ((GString *) cur->data)->len);
-
+ medium = cr_string_dup2 ((CRString *) cur->data);
if (medium == NULL)
continue;
-
fprintf (stdout, "medium: %s\n", medium);
-
if (medium) {
g_free (medium);
medium = NULL;
}
}
}
-
fprintf (stdout, "***************\n\n");
}
static void
-test_end_media (CRDocHandler * a_handler, GList * a_media_list)
+test_end_media (CRDocHandler * a_handler,
+ GList * a_media_list)
{
g_return_if_fail (a_handler);
@@ -357,28 +338,24 @@ test_end_media (CRDocHandler * a_handler, GList * a_media_list)
for (cur = a_media_list; cur; cur = cur->next) {
if (cur->data == NULL)
continue;
-
- medium = g_strndup (((GString *) cur->data)->str,
- ((GString *) cur->data)->len);
-
+ medium = cr_string_dup2 ((CRString *) cur->data);
if (medium == NULL)
continue;
-
fprintf (stdout, "medium: %s\n", medium);
-
if (medium) {
g_free (medium);
medium = NULL;
}
}
}
-
fprintf (stdout, "***************\n\n");
}
static void
test_start_page (CRDocHandler * a_handler,
- GString * a_name, GString * a_pseudo_page)
+ CRString * a_name,
+ CRString * a_pseudo_page,
+ CRParsingLocation *a_location)
{
guchar *name = NULL,
*pseudo_page = NULL;
@@ -388,30 +365,23 @@ test_start_page (CRDocHandler * a_handler,
fprintf (stdout, "***************\n");
fprintf (stdout, "start_page\n");
- if (a_name && a_name->str) {
- name = g_strndup (a_name->str, a_name->len);
+ if (a_name) {
+ name = cr_string_dup2 (a_name);
}
-
- if (a_pseudo_page && a_pseudo_page->str) {
- pseudo_page = g_strndup (a_pseudo_page->str,
- a_pseudo_page->len);
+ if (a_pseudo_page) {
+ pseudo_page = cr_string_dup2 (a_pseudo_page);
}
-
if (name) {
fprintf (stdout, "%s", name);
}
-
if (pseudo_page) {
fprintf (stdout, ": %s\n", pseudo_page);
}
-
fprintf (stdout, "***************\n\n");
-
if (name) {
g_free (name);
name = NULL;
}
-
if (pseudo_page) {
g_free (pseudo_page);
pseudo_page = NULL;
@@ -420,41 +390,34 @@ test_start_page (CRDocHandler * a_handler,
static void
test_end_page (CRDocHandler * a_handler,
- GString * a_name, GString * a_pseudo_page)
+ CRString * a_name,
+ CRString * a_pseudo_page)
{
guchar *name = NULL,
*pseudo_page = NULL;
g_return_if_fail (a_handler);
-
fprintf (stdout, "***************\n");
fprintf (stdout, "end_page\n");
- if (a_name && a_name->str) {
- name = g_strndup (a_name->str, a_name->len);
+ if (a_name) {
+ name = cr_string_dup2 (a_name);
}
-
- if (a_pseudo_page && a_pseudo_page->str) {
- pseudo_page = g_strndup (a_pseudo_page->str,
- a_pseudo_page->len);
+ if (a_pseudo_page) {
+ pseudo_page = cr_string_dup2 (a_pseudo_page) ;
}
-
if (name) {
fprintf (stdout, "%s", name);
}
-
if (pseudo_page) {
fprintf (stdout, ": %s\n", pseudo_page);
}
-
fprintf (stdout, "***************\n\n");
-
if (name) {
g_free (name);
name = NULL;
}
-
if (pseudo_page) {
g_free (pseudo_page);
pseudo_page = NULL;
@@ -462,7 +425,8 @@ test_end_page (CRDocHandler * a_handler,
}
static void
-test_ignorable_at_rule (CRDocHandler * a_handler, GString * a_name)
+test_ignorable_at_rule (CRDocHandler * a_handler,
+ CRString * a_name)
{
guchar *name = NULL;
@@ -471,14 +435,12 @@ test_ignorable_at_rule (CRDocHandler * a_handler, GString * a_name)
fprintf (stdout, "*********************\n");
fprintf (stdout, "ignorable_at_rule\n");
- if (a_name && a_name->str) {
- name = g_strndup (a_name->str, a_name->len);
+ if (a_name) {
+ name = cr_string_dup2 (a_name);
}
-
if (name) {
fprintf (stdout, "%s\n", name);
}
-
fprintf (stdout, "*********************\n\n");
}
diff --git a/tests/test4-main.c b/tests/test4-main.c
index 78501dc..f6365fc 100644
--- a/tests/test4-main.c
+++ b/tests/test4-main.c
@@ -17,12 +17,10 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
+ * Author: Dodji Seketeli
* See COPYRIGHTS file for copyrights information.
*/
-/*
- *$Id$
- */
#include "cr-test-utils.h"
#include "libcroco.h"