summaryrefslogtreecommitdiffstats
path: root/src/devices/grotty/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 19:44:05 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 19:44:05 +0000
commitd318611dd6f23fcfedd50e9b9e24620b102ba96a (patch)
tree8b9eef82ca40fdd5a8deeabf07572074c236095d /src/devices/grotty/tests
parentInitial commit. (diff)
downloadgroff-upstream.tar.xz
groff-upstream.zip
Adding upstream version 1.23.0.upstream/1.23.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/devices/grotty/tests')
-rwxr-xr-xsrc/devices/grotty/tests/basic_latin_glyphs_map_correctly.sh205
-rwxr-xr-xsrc/devices/grotty/tests/osc8_works.sh119
2 files changed, 324 insertions, 0 deletions
diff --git a/src/devices/grotty/tests/basic_latin_glyphs_map_correctly.sh b/src/devices/grotty/tests/basic_latin_glyphs_map_correctly.sh
new file mode 100755
index 0000000..92552d2
--- /dev/null
+++ b/src/devices/grotty/tests/basic_latin_glyphs_map_correctly.sh
@@ -0,0 +1,205 @@
+#!/bin/sh
+#
+# Copyright (C) 2022 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# groff is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# groff is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+grotty="${abs_top_builddir:-.}/grotty"
+
+fail=
+
+wail () {
+ printf "FAILED " >&2
+ fail=YES
+}
+
+# Ensure that characters are mapped to glyphs normatively.
+
+input='x T @DEVICE@
+x res 240 24 40
+x init
+p1
+x font 1 R
+f1
+s10
+V40
+H0
+md
+DFd
+t!#$%&()*+,./0123456789:;<=>?@
+n40 0
+V80
+H0
+tABCDEFGHIJKLMNOPQRSTUVWXYZ[]_
+n40 0
+V120
+H0
+tabcdefghijklmnopqrstuvwxyz{|}
+n40 0
+V160
+H0
+tneutral
+wh24
+tdouble
+wh24
+tquote:
+wh24
+Cdq
+h24
+n40 0
+V200
+H0
+tclosing
+wh24
+tsingle
+wh24
+tquote:
+wh24
+t'"'"'
+n40 0
+V240
+H0
+thyphen:
+wh24
+t-
+n40 0
+V280
+H0
+tbackslash:
+wh24
+Crs
+h24
+n40 0
+V320
+H0
+tmodifier
+wh24
+tcircumflex:
+wh24
+t^
+n40 0
+V360
+H0
+topening
+wh24
+tsingle
+wh24
+tquote:
+wh24
+t`
+n40 0
+V400
+H0
+tmodifier
+wh24
+ttilde:
+wh24
+t~
+n40 0
+x trailer
+V2640
+x stop'
+
+# TODO: Test cp1047 when we have access to a host environment using it.
+
+for D in ascii latin1 utf8
+do
+ if [ "$D" = "utf8" ]
+ then
+ # We can't test UTF-8 if the environment doesn't support it.
+ if [ "$(locale charmap)" != UTF-8 ]
+ then
+ # If we've already seen a failure case, report it.
+ if [ -n "$fail" ]
+ then
+ exit 1 # fail
+ else
+ exit 77 # skip
+ fi
+ fi
+ fi
+
+ printf 'checking "%s" output device...' $D >&2
+ output=$(echo "$input" | sed s/@DEVICE@/$D/ \
+ | "$grotty" -F font -F build/font)
+ printf 'group1 ' >&2
+ echo "$output" | grep -Fqx '!#$%&()*+,./0123456789:;<=>?@' || wail
+ printf 'group2 ' >&2
+ echo "$output" | grep -Fqx 'ABCDEFGHIJKLMNOPQRSTUVWXYZ[]_' || wail
+ printf 'group3 ' >&2
+ echo "$output" | grep -Fqx 'abcdefghijklmnopqrstuvwxyz{|}' || wail
+ printf '" ' >&2
+ echo "$output" | grep -Fqx 'neutral double quote: "' || wail
+ printf '\\ ' >&2
+ echo "$output" | grep -Fqx 'backslash: \' || wail
+ case $D in
+ (utf8)
+# Expected:
+#0000000 ! # $ % & ( ) * + , . / 0 1 2 3
+#0000020 4 5 6 7 8 9 : ; < = > ? @ \n A B
+#0000040 C D E F G H I J K L M N O P Q R
+#0000060 S T U V W X Y Z [ ] _ \n a b c d
+#0000100 e f g h i j k l m n o p q r s t
+#0000120 u v w x y z { | } \n n e u t r a
+#0000140 l d o u b l e q u o t e :
+#0000160 " \n c l o s i n g s i n g l e
+#0000200 q u o t e : 342 200 231 \n h y p h
+#0000220 e n : 342 200 220 \n b a c k s l a s
+#0000240 h : \ \n m o d i f i e r c i
+#0000260 r c u m f l e x : 313 206 \n o p e
+#0000300 n i n g s i n g l e q u o t
+#0000320 e : 342 200 230 \n m o d i f i e r
+#0000340 t i l d e : 313 234 \n
+#0000352
+ output_od=$(echo "$output" | LC_ALL=C od -t c)
+ printf "' " >&2
+ printf '%s\n' "$output_od" \
+ | grep -Eq '0000200 +q +u +o +t +e +: +342 +200 +231' \
+ || wail
+ printf '` ' >&2
+ printf '%s\n' "$output_od" \
+ | grep -Eq '0000320 +e +: +342 +200 +230' || wail
+ printf "%s " '-' >&2
+ printf '%s\n' "$output_od" \
+ | grep -Eq '0000220 +e +n +: +342 +200 +220' || wail
+ printf '^ ' >&2
+ printf '%s\n' "$output_od" \
+ | grep -Eq '0000260 +r +c +u +m +f +l +e +x +: +313 +206' \
+ || wail
+ printf "~ " >&2
+ printf '%s\n' "$output_od" \
+ | grep -Eq '0000340 +t +i +l +d +e +: +313 +234' || wail
+ ;;
+ (*)
+ printf '` ' >&2
+ echo "$output" | grep -Fqx 'opening single quote: `' || wail
+ printf "' " >&2
+ echo "$output" | grep -Fqx "closing single quote: '" || wail
+ printf "%s " '-' >&2
+ echo "$output" | grep -Fqx "hyphen: -" || wail
+ printf '^ ' >&2
+ echo "$output" | grep -Fqx "modifier circumflex: ^" || wail
+ printf "~ " >&2
+ echo "$output" | grep -Fqx "modifier tilde: ~" || wail
+ ;;
+ esac
+ echo >&2
+done
+
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/src/devices/grotty/tests/osc8_works.sh b/src/devices/grotty/tests/osc8_works.sh
new file mode 100755
index 0000000..db6480d
--- /dev/null
+++ b/src/devices/grotty/tests/osc8_works.sh
@@ -0,0 +1,119 @@
+#!/bin/sh
+#
+# Copyright (C) 2021 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# groff is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# groff is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+set -e
+
+grotty="${abs_top_builddir:-.}/grotty"
+
+input="x T utf8
+x res 240 24 40
+x init
+p1
+x font 1 R
+f1
+s10
+V40
+H0
+md
+DFd
+tA
+n40 0
+x X tty: link
+x X tty: link h
+x X tty: link http://example.com/1
+x X tty: link
+x X tty: link http://example.com/2
+tB
+x X tty: link
+x X tty: link mailto:g.branden.robinson@gmail.com
+tBranden
+x X tty: link
+x trailer
+V2640
+x stop"
+
+# We expect diagnostics from the first few "x X tty: link" lines. The
+# first should complain about a link ending without having been started.
+# The second is bogus ("h") but it's not grotty's job to validate the
+# structure of a URI. The third should draw complaint because we didn't
+# end the (bogus) URI that we started with the second.
+
+# The remaining input is well-formed. The URI ending in "1" is
+# effectively hidden because no character cells are drawn while it is
+# active.
+echo "expect two diagnostic messages regarding ill-formed links" >&2
+output=$(echo "$input" | "$grotty" -F font -F build/font | od -t c)
+
+# Expected:
+#0000000 A 033 ] 8 ; ; 033 \ 033 ] 8 ; ; h 033 \
+#0000020 033 ] 8 ; ; 033 \ 033 ] 8 ; ; h t t p
+#0000040 : / / e x a m p l e . c o m / 1
+#0000060 033 \ 033 ] 8 ; ; 033 \ 033 ] 8 ; ; h t
+#0000100 t p : / / e x a m p l e . c o m
+#0000120 / 2 033 \ B 033 ] 8 ; ; 033 \ 033 ] 8 ;
+#0000140 ; m a i l t o : g . b r a n d e
+#0000160 n . r o b i n s o n @ g m a i l
+#0000200 . c o m 033 \ B r a n d e n 033 ] 8
+#0000220 ; ; 033 \ \n \n \n \n \n \n \n \n \n \n \n \n
+#0000240 \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
+#*
+#0000320 \n \n \n \n \n \n
+#0000326
+
+echo "testing for URI that corresponds to no character cells" >&2
+echo "$output" | grep -Eq 'A 033 +] +8 +; +; +033 +\\'
+
+echo "testing http URI (1)" >&2
+echo "$output" | grep -Eq '0000020 +.*033 +] +8 +; +; +h + t +t +p'
+
+echo "testing http URI (2)" >&2
+echo "$output" | grep -Eq '0000040 +: +/ +/ +e +x +a +m +p +l +e +\. +c'
+
+echo "testing http URI (3)" >&2
+echo "$output" | grep -Eq '0000040.* +o +m +/ +1'
+
+echo "testing http URI (4)" >&2
+echo "$output" | grep -Eq '0000060 +033 +\\'
+
+echo "testing mailto URI (1)" >&2
+echo "$output" | grep -Eq '0000120 +.* +033 +] +8 +;$'
+
+echo "testing mailto URI (2)" >&2
+echo "$output" | grep -Eq '0000140 +; +m +a +i +l +t +o +: +g +\. +b'
+
+echo "testing mailto URI (3)" >&2
+echo "$output" | grep -Eq '0000140.* +r +a +n +d +e$'
+
+echo "testing mailto URI (4)" >&2
+echo "$output" | grep -Eq '0000160 +n +\. +r +o +b +i +n +s +o +n +@'
+
+echo "testing mailto URI (5)" >&2
+echo "$output" | grep -Eq '0000160.* +g +m +a +i +l$'
+
+echo "testing mailto URI (6)" >&2
+echo "$output" | grep -Eq '0000200 +\. +c +o +m +033 +\\ +B +r +a +n +d'
+
+echo "testing mailto URI (7)" >&2
+echo "$output" | grep -Eq '0000200.* +e +n +033 +] +8$'
+
+echo "testing mailto URI (8)" >&2
+echo "$output" | grep -Eq '0000220 +; +; +033 +\\'
+
+# vim:set ai et sw=4 ts=4 tw=72: