From ba5dbd3a180915f934320706dd3296b76e0b1313 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Thu, 29 Dec 2005 06:54:41 +0100 Subject: [PATCH] Add test_output_equals helper and add a few more tests The last one fails for now. Incorrect parsing of processing instructions. --- src/dom/test/test-sgml-parser-basic | 95 ++++++++++++++++++++++++----- 1 file changed, 80 insertions(+), 15 deletions(-) diff --git a/src/dom/test/test-sgml-parser-basic b/src/dom/test/test-sgml-parser-basic index 8b40d51df..9c26420be 100755 --- a/src/dom/test/test-sgml-parser-basic +++ b/src/dom/test/test-sgml-parser-basic @@ -11,24 +11,89 @@ correctly in the DOM tree. . ./libtest +test_output_equals () { + desc="$1" + src="$2" + out="$3" + + URI="test:$(echo "$desc" | sed ' + s/^[ \t]*\[[^]]*\][ \t]*//; + s/[:., \t][:., \t]*/-/g; + s/_/-/g; + # *cough* + y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/; + s/[^a-zA-Z0-9-]//g;')" + + sgml-parser --uri "$URI" --src "$src" | sed 's/^ //' > output + echo "#document: $URI" > expected + echo "$out" | sed -n '2,$p' >> expected + + test_expect_success "$desc" 'cmp -b output expected' +} + + ################################################################ -# init-db has been done in an empty repository. -# make sure it is empty. +# Parse various SGML node types. -sgml-parser --uri "test:hello-world" \ - --src "

Hello World!

" \ - > output +test_output_equals \ +'Parse a small document.' \ +'

Hello World!

' \ +' +element: html + element: body + element: p + #text: Hello World!' -cat > expected <' \ +' +element: root + #comment: Hello World! ' -test_expect_success \ - 'Test a small document.' \ - 'cmp output expected' +test_output_equals \ +'Parse an enclosed CDATA section.' \ +'...]]>' \ +' +element: root + #cdata-section: ...] ]>...' + +test_output_equals \ +'Parse attributes.' \ +'' \ +' +element: root + attribute: lang -> fr + attribute: attr -> + attribute: name -> value with &foo; &...*...&...copy;...&;...&#;' \ +' +element: root + entity-reference: amp + #text: ... + entity-reference: #42 + #text: ... + entity-reference: ...copy + #text: ... + #text: &; + #text: ... + entity-reference: #' + +# Test +test_output_equals \ +'Parse processing instructions.' \ +' +... +' \ +' +proc-instruction: xml -> encoding="UTF8" + attribute: encoding -> UTF8 +#text: \n...\n +proc-instruction: ecmascript -> \nvar -> val=2;\n' test_done