mirror of
https://github.com/rkd77/elinks.git
synced 2025-01-03 14:57:44 -05:00
Move line counting tests to own file; simplifies a few things
This commit is contained in:
parent
dee8ac5b45
commit
f1c3c90a4f
@ -104,7 +104,8 @@ sgml_parser_test_tree(struct dom_stack *stack, struct dom_node *node, void *data
|
|||||||
struct dom_string *name = get_dom_node_name(node);
|
struct dom_string *name = get_dom_node_name(node);
|
||||||
|
|
||||||
/* Always print the URI for identification. */
|
/* Always print the URI for identification. */
|
||||||
update_number_of_lines(stack);
|
if (update_number_of_lines(stack))
|
||||||
|
return;
|
||||||
|
|
||||||
print_indent(stack);
|
print_indent(stack);
|
||||||
printf("%.*s: %.*s\n",
|
printf("%.*s: %.*s\n",
|
||||||
|
@ -24,7 +24,7 @@ test_output_equals () {
|
|||||||
y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/;
|
y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/;
|
||||||
s/[^a-zA-Z0-9-]//g;')"
|
s/[^a-zA-Z0-9-]//g;')"
|
||||||
|
|
||||||
sgml-parser --uri "$URI" --src "$src" $@ | sed 's/^ //' > output
|
sgml-parser --uri "$URI" --src "$src" | sed 's/^ //' > output
|
||||||
echo "#document: $URI" > expected
|
echo "#document: $URI" > expected
|
||||||
echo "$out" | sed -n '2,$p' >> expected
|
echo "$out" | sed -n '2,$p' >> expected
|
||||||
|
|
||||||
@ -247,41 +247,4 @@ element: root
|
|||||||
attribute: ns:attr -> value
|
attribute: ns:attr -> value
|
||||||
proc-instruction: target -> data'
|
proc-instruction: target -> data'
|
||||||
|
|
||||||
test_output_equals \
|
|
||||||
'Check line numbers. (I)' \
|
|
||||||
'<!-- line --> number <one />' \
|
|
||||||
'
|
|
||||||
1' \
|
|
||||||
--print-lines
|
|
||||||
|
|
||||||
test_output_equals \
|
|
||||||
'Check line numbers. (II)' \
|
|
||||||
'<
|
|
||||||
line:2
|
|
||||||
line:3
|
|
||||||
=
|
|
||||||
"line:5"
|
|
||||||
><?xml
|
|
||||||
line:7="..."
|
|
||||||
line:8
|
|
||||||
=
|
|
||||||
'\''...'\''></line:10>' \
|
|
||||||
'
|
|
||||||
10' \
|
|
||||||
--print-lines
|
|
||||||
|
|
||||||
test_output_equals \
|
|
||||||
'Check line numbers. (III)' \
|
|
||||||
'1
|
|
||||||
2
|
|
||||||
3
|
|
||||||
4
|
|
||||||
5
|
|
||||||
6
|
|
||||||
7
|
|
||||||
8' \
|
|
||||||
'
|
|
||||||
8' \
|
|
||||||
--print-lines
|
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
67
src/dom/test/test-sgml-parser-lines
Executable file
67
src/dom/test/test-sgml-parser-lines
Executable file
@ -0,0 +1,67 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Copyright (c) 2005 Jonas Fonseca
|
||||||
|
#
|
||||||
|
|
||||||
|
test_description='Test the SGML parsers counting of lines
|
||||||
|
|
||||||
|
Checks that the SGML parser correctly reports how many lines the
|
||||||
|
source has.
|
||||||
|
'
|
||||||
|
|
||||||
|
. "$TEST_LIB"
|
||||||
|
|
||||||
|
test_output_line_numbers () {
|
||||||
|
desc="$1"; shift
|
||||||
|
src="$1"; shift
|
||||||
|
expected_lines="$1"; shift
|
||||||
|
|
||||||
|
URI="test:$(echo "$desc" | sed '
|
||||||
|
s/^[ \t]*\[[^]]*\][ \t]*//;
|
||||||
|
s/[:., \t][:., \t]*/-/g;
|
||||||
|
s/_/-/g;
|
||||||
|
# *cough*
|
||||||
|
y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/;
|
||||||
|
s/[^a-zA-Z0-9-]//g;')"
|
||||||
|
|
||||||
|
lines=$(sgml-parser --uri "$URI" --src "$src" --print-lines)
|
||||||
|
|
||||||
|
test_expect_success "$desc" "test $lines = $expected_lines"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
################################################################
|
||||||
|
# Check line numbers
|
||||||
|
|
||||||
|
test_output_line_numbers \
|
||||||
|
'Check line numbers. (I)' \
|
||||||
|
'<!-- line --> number <one />' \
|
||||||
|
1
|
||||||
|
|
||||||
|
test_output_line_numbers \
|
||||||
|
'Check line numbers. (II)' \
|
||||||
|
'<
|
||||||
|
line:2
|
||||||
|
line:3
|
||||||
|
=
|
||||||
|
"line:5"
|
||||||
|
><?xml
|
||||||
|
line:7="..."
|
||||||
|
line:8
|
||||||
|
=
|
||||||
|
'\''...'\''></line:10>' \
|
||||||
|
10
|
||||||
|
|
||||||
|
test_output_line_numbers \
|
||||||
|
'Check line numbers. (III)' \
|
||||||
|
'1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
4
|
||||||
|
5
|
||||||
|
6
|
||||||
|
7
|
||||||
|
8' \
|
||||||
|
8
|
||||||
|
|
||||||
|
test_done
|
Loading…
Reference in New Issue
Block a user