1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-10-01 03:36:26 -04:00

Move line counting tests to own file; simplifies a few things

This commit is contained in:
Jonas Fonseca 2006-01-07 02:02:21 +01:00 committed by Jonas Fonseca
parent dee8ac5b45
commit f1c3c90a4f
3 changed files with 70 additions and 39 deletions

View File

@ -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);
/* Always print the URI for identification. */
update_number_of_lines(stack);
if (update_number_of_lines(stack))
return;
print_indent(stack);
printf("%.*s: %.*s\n",

View File

@ -24,7 +24,7 @@ test_output_equals () {
y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/;
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 "$out" | sed -n '2,$p' >> expected
@ -247,41 +247,4 @@ element: root
attribute: ns:attr -> value
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

View 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