diff --git a/src/dom/test/sgml-parser.c b/src/dom/test/sgml-parser.c index 7c7f56ec..9dfe1f1a 100644 --- a/src/dom/test/sgml-parser.c +++ b/src/dom/test/sgml-parser.c @@ -21,7 +21,7 @@ static void print_compressed_string(struct dom_string *string) { - unsigned char escape[2] = "\\"; + unsigned char escape[3] = { '\\', '?', 0 }; size_t pos; for (pos = 0; pos < string->length; pos++) { @@ -142,8 +142,8 @@ struct dom_stack_context_info sgml_parser_test_context_info = { /* DOM_NODE_ELEMENT */ sgml_parser_test_branch, /* DOM_NODE_ATTRIBUTE */ sgml_parser_test_id_leaf, /* DOM_NODE_TEXT */ sgml_parser_test_leaf, - /* DOM_NODE_CDATA_SECTION */ sgml_parser_test_id_leaf, - /* DOM_NODE_ENTITY_REFERENCE */ sgml_parser_test_id_leaf, + /* DOM_NODE_CDATA_SECTION */ sgml_parser_test_leaf, + /* DOM_NODE_ENTITY_REFERENCE */ sgml_parser_test_branch, /* DOM_NODE_ENTITY */ sgml_parser_test_id_leaf, /* DOM_NODE_PROC_INSTRUCTION */ sgml_parser_test_id_leaf, /* DOM_NODE_COMMENT */ sgml_parser_test_leaf, diff --git a/src/dom/test/test-sgml-parser-basic b/src/dom/test/test-sgml-parser-basic index 8b40d51d..9c26420b 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 <