mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Merge with git+ssh://pasky.or.cz/srv/git/elinks.git
This commit is contained in:
commit
898c2a8165
@ -21,7 +21,7 @@
|
|||||||
static void
|
static void
|
||||||
print_compressed_string(struct dom_string *string)
|
print_compressed_string(struct dom_string *string)
|
||||||
{
|
{
|
||||||
unsigned char escape[2] = "\\";
|
unsigned char escape[3] = { '\\', '?', 0 };
|
||||||
size_t pos;
|
size_t pos;
|
||||||
|
|
||||||
for (pos = 0; pos < string->length; 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_ELEMENT */ sgml_parser_test_branch,
|
||||||
/* DOM_NODE_ATTRIBUTE */ sgml_parser_test_id_leaf,
|
/* DOM_NODE_ATTRIBUTE */ sgml_parser_test_id_leaf,
|
||||||
/* DOM_NODE_TEXT */ sgml_parser_test_leaf,
|
/* DOM_NODE_TEXT */ sgml_parser_test_leaf,
|
||||||
/* DOM_NODE_CDATA_SECTION */ sgml_parser_test_id_leaf,
|
/* DOM_NODE_CDATA_SECTION */ sgml_parser_test_leaf,
|
||||||
/* DOM_NODE_ENTITY_REFERENCE */ sgml_parser_test_id_leaf,
|
/* DOM_NODE_ENTITY_REFERENCE */ sgml_parser_test_branch,
|
||||||
/* DOM_NODE_ENTITY */ sgml_parser_test_id_leaf,
|
/* DOM_NODE_ENTITY */ sgml_parser_test_id_leaf,
|
||||||
/* DOM_NODE_PROC_INSTRUCTION */ sgml_parser_test_id_leaf,
|
/* DOM_NODE_PROC_INSTRUCTION */ sgml_parser_test_id_leaf,
|
||||||
/* DOM_NODE_COMMENT */ sgml_parser_test_leaf,
|
/* DOM_NODE_COMMENT */ sgml_parser_test_leaf,
|
||||||
|
@ -11,24 +11,89 @@ correctly in the DOM tree.
|
|||||||
|
|
||||||
. ./libtest
|
. ./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.
|
# Parse various SGML node types.
|
||||||
# make sure it is empty.
|
|
||||||
|
|
||||||
sgml-parser --uri "test:hello-world" \
|
test_output_equals \
|
||||||
--src "<html><body><p>Hello World!</p></body></html>" \
|
'Parse a small document.' \
|
||||||
> output
|
'<html><body><p>Hello World!</p></body></html>' \
|
||||||
|
'
|
||||||
|
element: html
|
||||||
|
element: body
|
||||||
|
element: p
|
||||||
|
#text: Hello World!'
|
||||||
|
|
||||||
cat > expected <<EOF
|
test_output_equals \
|
||||||
#document: test:hello-world
|
'Parse an enclosed comment.' \
|
||||||
element: html
|
'<root><!-- Hello World! --></root>' \
|
||||||
element: body
|
'
|
||||||
element: p
|
element: root
|
||||||
#text: Hello World!
|
#comment: Hello World! '
|
||||||
EOF
|
|
||||||
|
|
||||||
test_expect_success \
|
test_output_equals \
|
||||||
'Test a small document.' \
|
'Parse an enclosed CDATA section.' \
|
||||||
'cmp output expected'
|
'<root><![CDATA[...] ]>...]]></root>' \
|
||||||
|
'
|
||||||
|
element: root
|
||||||
|
#cdata-section: ...] ]>...'
|
||||||
|
|
||||||
|
test_output_equals \
|
||||||
|
'Parse attributes.' \
|
||||||
|
'<root lang="fr" attr name="value with &foo; <stuff"></root>' \
|
||||||
|
'
|
||||||
|
element: root
|
||||||
|
attribute: lang -> fr
|
||||||
|
attribute: attr ->
|
||||||
|
attribute: name -> value with &foo; <stuff'
|
||||||
|
|
||||||
|
test_output_equals \
|
||||||
|
'Parse entity references.' \
|
||||||
|
'<root>&...*...&...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.' \
|
||||||
|
'<?xml encoding="UTF8"?>
|
||||||
|
...
|
||||||
|
<?ecmascript
|
||||||
|
var val=2;
|
||||||
|
?>' \
|
||||||
|
'
|
||||||
|
proc-instruction: xml -> encoding="UTF8"
|
||||||
|
attribute: encoding -> UTF8
|
||||||
|
#text: \n...\n
|
||||||
|
proc-instruction: ecmascript -> \nvar -> val=2;\n'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
Loading…
Reference in New Issue
Block a user