groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 14/45: [grotty]: Check basic Latin ("ASCII") mappings.


From: G. Branden Robinson
Subject: [groff] 14/45: [grotty]: Check basic Latin ("ASCII") mappings.
Date: Thu, 20 Jan 2022 10:17:49 -0500 (EST)

gbranden pushed a commit to branch master
in repository groff.

commit d0323e0c13ee8d2667df30a399ee37947ec39376
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sat Jan 15 14:04:10 2022 +1100

    [grotty]: Check basic Latin ("ASCII") mappings.
    
    * src/devices/grotty/tests/basic_latin_glyphs_map_correctly.sh: Do it.
    * src/devices/grotty/grotty.am (grotty_TESTS): Run test.
    
    (Milestone: This is our 100th automated test.  I didn't add it to move
    odometer rollers, though; the behavior of glyphuni.cpp surprised me and
    I think I can simplify the devutf8 R.proto file, but I want to guard
    against regressions.)
---
 ChangeLog                                          |   8 +
 src/devices/grotty/grotty.am                       |   1 +
 .../tests/basic_latin_glyphs_map_correctly.sh      | 190 +++++++++++++++++++++
 3 files changed, 199 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 0fb1b009..ef058fc6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2022-01-15  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       [grotty]: Check basic Latin ("ASCII") glyph mappings.
+
+       * src/devices/grotty/tests/basic_latin_glyphs_map_correctly.sh:
+       Do it.
+       * src/devices/grotty/grotty.am (grotty_TESTS): Run test.
+
 2022-01-15  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        [font,tmac]: Simplify Unicode character mapping process.
diff --git a/src/devices/grotty/grotty.am b/src/devices/grotty/grotty.am
index a7410016..14921c56 100644
--- a/src/devices/grotty/grotty.am
+++ b/src/devices/grotty/grotty.am
@@ -27,6 +27,7 @@ EXTRA_DIST += \
   src/devices/grotty/TODO
 
 grotty_TESTS = \
+  src/devices/grotty/tests/basic_latin_glyphs_map_correctly.sh \
   src/devices/grotty/tests/osc8_works.sh
 TESTS += $(grotty_TESTS)
 EXTRA_DIST += $(grotty_TESTS)
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 00000000..00123f5d
--- /dev/null
+++ b/src/devices/grotty/tests/basic_latin_glyphs_map_correctly.sh
@@ -0,0 +1,190 @@
+#!/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
+    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" | 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:



reply via email to

[Prev in Thread] Current Thread [Next in Thread]