diff --git a/ChangeLog b/ChangeLog index 5db5a35e6..fb1f1cc22 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2006-05-28 Matthias Clasen + + * tests/markups/expected-*: Output that test-markup + is expected to produce when run on the valid gmarkup + examples. + + * tests/markup-test.c: Only dump the results of the + first, unchunked parse, to compare it against the expected + output. + + * tests/run-markup-tests.sh: For valid examples, compare + the output of test-markup against the corresponding + expected- file. + 2006-05-24 Matthias Clasen * configure.in: Don't compile timeloop on Minix. diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 5db5a35e6..fb1f1cc22 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,17 @@ +2006-05-28 Matthias Clasen + + * tests/markups/expected-*: Output that test-markup + is expected to produce when run on the valid gmarkup + examples. + + * tests/markup-test.c: Only dump the results of the + first, unchunked parse, to compare it against the expected + output. + + * tests/run-markup-tests.sh: For valid examples, compare + the output of test-markup against the corresponding + expected- file. + 2006-05-24 Matthias Clasen * configure.in: Don't compile timeloop on Minix. diff --git a/tests/markup-test.c b/tests/markup-test.c index af19a5ee3..6d5f44b65 100644 --- a/tests/markup-test.c +++ b/tests/markup-test.c @@ -54,10 +54,10 @@ end_element_handler (GMarkupParseContext *context, --depth; indent (0); printf ("END '%s'\n", element_name); -} + } static void -text_handler (GMarkupParseContext *context, +text_handler (GMarkupParseContext *context, const gchar *text, gsize text_len, gpointer user_data, @@ -88,7 +88,7 @@ error_handler (GMarkupParseContext *context, fprintf (stderr, " %s\n", error->message); } -static GMarkupParser parser = { +static const GMarkupParser parser = { start_element_handler, end_element_handler, text_handler, @@ -96,6 +96,14 @@ static GMarkupParser parser = { error_handler }; +static const GMarkupParser silent_parser = { + NULL, + NULL, + NULL, + NULL, + error_handler +}; + static int test_in_chunks (const gchar *contents, gint length, @@ -104,7 +112,7 @@ test_in_chunks (const gchar *contents, GMarkupParseContext *context; int i = 0; - context = g_markup_parse_context_new (&parser, 0, NULL, NULL); + context = g_markup_parse_context_new (&silent_parser, 0, NULL, NULL); while (i < length) { diff --git a/tests/markups/expected-1 b/tests/markups/expected-1 new file mode 100644 index 000000000..8b6cdd77c --- /dev/null +++ b/tests/markups/expected-1 @@ -0,0 +1,37 @@ +PASS '' +PASS '' +ELEMENT 'foobar' + TEXT ' +' + ELEMENT 'e1' + TEXT 'Hi & this is some text inside an element Two 'E' chars as character refs: E E and some 'J': J J' + END 'e1' + TEXT ' +' + ELEMENT 'e2:foo' + TEXT ' Text ' + ELEMENT 'childfree' + END 'childfree' + TEXT ' with some ' + ELEMENT 'nested' + TEXT 'nested elements' + END 'nested' + TEXT ' and entities "& < >> ' and whitespace ' + END 'e2:foo' + TEXT ' +' + ELEMENT 'tag' + ab="fo' +ELEMENT 'foo' + TEXT '' +END 'foo' diff --git a/tests/markups/expected-6 b/tests/markups/expected-6 new file mode 100644 index 000000000..bfb41cefc --- /dev/null +++ b/tests/markups/expected-6 @@ -0,0 +1,6 @@ +PASS ' +]>' +ELEMENT 'foo' + TEXT '' +END 'foo' diff --git a/tests/markups/expected-7 b/tests/markups/expected-7 new file mode 100644 index 000000000..2fe197564 --- /dev/null +++ b/tests/markups/expected-7 @@ -0,0 +1,4 @@ +PASS '' +ELEMENT 'foo' + TEXT '' +END 'foo' diff --git a/tests/markups/expected-8 b/tests/markups/expected-8 new file mode 100644 index 000000000..5bbda0421 --- /dev/null +++ b/tests/markups/expected-8 @@ -0,0 +1,5 @@ +ELEMENT 'foo' + TEXT '' + PASS '>>> CDATA ]]>' + TEXT '' +END 'foo' diff --git a/tests/markups/expected-9 b/tests/markups/expected-9 new file mode 100644 index 000000000..781039429 --- /dev/null +++ b/tests/markups/expected-9 @@ -0,0 +1,3 @@ +ELEMENT 'foo' + TEXT 'data' +END 'foo' diff --git a/tests/run-markup-tests.sh b/tests/run-markup-tests.sh index 94ec14381..db6b47455 100755 --- a/tests/run-markup-tests.sh +++ b/tests/run-markup-tests.sh @@ -17,7 +17,7 @@ error_out=/dev/null if [ "$1" = "-v" ]; then verbose=1 error_out=/dev/stderr -fi +fi for I in ${srcdir:-.}/markups/fail-*.gmarkup; do echo_v "Parsing $I, should fail" ./markup-test $I > /dev/null 2> $error_out && fail "failed to generate error on $I" @@ -26,9 +26,14 @@ for I in ${srcdir:-.}/markups/fail-*.gmarkup; do fi done -for I in ${srcdir:-.}/markups/valid-*.gmarkup; do - echo_v "Parsing $I, should succeed" - ./markup-test $I > /dev/null 2> $error_out || fail "failed on $I" +for (( I=1 ; I < 100 ; I++ )) ; do + F=${srcdir:-.}/markups/valid-$I.gmarkup + if [ -f $F ] ; then + echo_v "Parsing $F, should succeed" + ./markup-test $F > actual 2> $error_out || fail "failed on $F" + diff -u ${srcdir:-.}/markups/expected-$I actual || fail "unexpected output on $F" + rm actual + fi done echo_v "All tests passed."