gbranden pushed a commit to branch branden-2023-07-05 in repository groff. commit 8c1757e57f5e5a854b390fb5098e89fe73ba2eb7 Author: G. Branden Robinson <g.branden.robin...@gmail.com> AuthorDate: Fri Jun 23 12:48:56 2023 -0500
[troff]: Add unit tests for drawing commands. * src/roff/groff/tests/draw-arc.sh: * src/roff/groff/tests/draw-circle.sh: * src/roff/groff/tests/draw-ellipse.sh: * src/roff/groff/tests/draw-filled-circle.sh: * src/roff/groff/tests/draw-filled-ellipse.sh: * src/roff/groff/tests/draw-filled-polygon.sh: * src/roff/groff/tests/draw-line.sh: * src/roff/groff/tests/draw-polygon.sh: * src/roff/groff/tests/draw-spline.sh: * src/roff/groff/tests/set-stroke-thickness.sh: Do it. * src/roff/groff/groff.am (groff_TESTS): Run tests. --- ChangeLog | 17 ++++++++++++ src/roff/groff/groff.am | 10 +++++++ src/roff/groff/tests/draw-arc.sh | 40 ++++++++++++++++++++++++++++ src/roff/groff/tests/draw-circle.sh | 40 ++++++++++++++++++++++++++++ src/roff/groff/tests/draw-ellipse.sh | 40 ++++++++++++++++++++++++++++ src/roff/groff/tests/draw-filled-circle.sh | 40 ++++++++++++++++++++++++++++ src/roff/groff/tests/draw-filled-ellipse.sh | 40 ++++++++++++++++++++++++++++ src/roff/groff/tests/draw-filled-polygon.sh | 40 ++++++++++++++++++++++++++++ src/roff/groff/tests/draw-line.sh | 40 ++++++++++++++++++++++++++++ src/roff/groff/tests/draw-polygon.sh | 40 ++++++++++++++++++++++++++++ src/roff/groff/tests/draw-spline.sh | 40 ++++++++++++++++++++++++++++ src/roff/groff/tests/set-stroke-thickness.sh | 40 ++++++++++++++++++++++++++++ 12 files changed, 427 insertions(+) diff --git a/ChangeLog b/ChangeLog index feb095558..12435043f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2023-06-23 G. Branden Robinson <g.branden.robin...@gmail.com> + + [troff]: Add unit tests for drawing commands. + + * src/roff/groff/tests/draw-arc.sh: + * src/roff/groff/tests/draw-circle.sh: + * src/roff/groff/tests/draw-ellipse.sh: + * src/roff/groff/tests/draw-filled-circle.sh: + * src/roff/groff/tests/draw-filled-ellipse.sh: + * src/roff/groff/tests/draw-filled-polygon.sh: + * src/roff/groff/tests/draw-line.sh: + * src/roff/groff/tests/draw-polygon.sh: + * src/roff/groff/tests/draw-spline.sh: + * src/roff/groff/tests/set-stroke-thickness.sh: Do it. + + * src/roff/groff/groff.am (groff_TESTS): Run tests. + 2023-06-08 G. Branden Robinson <g.branden.robin...@gmail.com> [man, mdoc]: Parameterize page offset. diff --git a/src/roff/groff/groff.am b/src/roff/groff/groff.am index 8937d4ced..306677bf9 100644 --- a/src/roff/groff/groff.am +++ b/src/roff/groff/groff.am @@ -44,6 +44,15 @@ groff_TESTS = \ src/roff/groff/tests/dot-cp_register_works.sh \ src/roff/groff/tests/dot-nm_register_works.sh \ src/roff/groff/tests/dot-nn_register_works.sh \ + src/roff/groff/tests/draw-arc.sh \ + src/roff/groff/tests/draw-circle.sh \ + src/roff/groff/tests/draw-ellipse.sh \ + src/roff/groff/tests/draw-filled-circle.sh \ + src/roff/groff/tests/draw-filled-ellipse.sh \ + src/roff/groff/tests/draw-filled-polygon.sh \ + src/roff/groff/tests/draw-line.sh \ + src/roff/groff/tests/draw-polygon.sh \ + src/roff/groff/tests/draw-spline.sh \ src/roff/groff/tests/evc_produces_no_output_if_invalid.sh \ src/roff/groff/tests/fp_should_not_traverse_directories.sh \ src/roff/groff/tests/handle_special_input_code_points.sh \ @@ -59,6 +68,7 @@ groff_TESTS = \ src/roff/groff/tests/regression_savannah_58162.sh \ src/roff/groff/tests/regression_savannah_58337.sh \ src/roff/groff/tests/regression_savannah_59202.sh \ + src/roff/groff/tests/set-stroke-thickness.sh \ src/roff/groff/tests/smoke-test_html_device.sh \ src/roff/groff/tests/some_escapes_accept_newline_delimiters.sh \ src/roff/groff/tests/soquiet_works.sh \ diff --git a/src/roff/groff/tests/draw-arc.sh b/src/roff/groff/tests/draw-arc.sh new file mode 100755 index 000000000..9118ba549 --- /dev/null +++ b/src/roff/groff/tests/draw-arc.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# +# Copyright (C) 2023 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/>. +# + +groff="${abs_top_builddir:-.}/test-groff" + +expected_line_1='t *A' +expected_line_2='D *a *10000 *12000 *10000 *12000' +expected_line_3='t *B' + +actual=$(printf 'A\\D@a 1 1 1 1@B\n' | "$groff" -Tps -Z) +echo "$actual" +# '/^t *A/{p;n;/^D *a/{p;n;/^t *B/p;}}' +actual=$(echo "$actual" \ + | sed -n -e '/^t *A/{' -e 'p;n;/^D *a/{' -e 'p;n;/^t *B/p;' -e '}' \ + -e '}') + +fail= + +echo "$actual" | sed -n '1p' | grep "$expected_line_1" || fail=yes +echo "$actual" | sed -n '2p' | grep "$expected_line_2" || fail=yes +echo "$actual" | sed -n '3p' | grep "$expected_line_3" || fail=yes + +test -z "$fail" diff --git a/src/roff/groff/tests/draw-circle.sh b/src/roff/groff/tests/draw-circle.sh new file mode 100755 index 000000000..9c1997032 --- /dev/null +++ b/src/roff/groff/tests/draw-circle.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# +# Copyright (C) 2023 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/>. +# + +groff="${abs_top_builddir:-.}/test-groff" + +expected_line_1='t *A' +expected_line_2='D *c *10000' +expected_line_3='t *B' + +actual=$(printf 'A\\D@c 1@B\n' | "$groff" -Tps -Z) +echo "$actual" +# '/^t *A/{p;n;/^D *c/{p;n;/^t *B/p;}}' +actual=$(echo "$actual" \ + | sed -n -e '/^t *A/{' -e 'p;n;/^D *c/{' -e 'p;n;/^t *B/p;' -e '}' \ + -e '}') + +fail= + +echo "$actual" | sed -n '1p' | grep "$expected_line_1" || fail=yes +echo "$actual" | sed -n '2p' | grep "$expected_line_2" || fail=yes +echo "$actual" | sed -n '3p' | grep "$expected_line_3" || fail=yes + +test -z "$fail" diff --git a/src/roff/groff/tests/draw-ellipse.sh b/src/roff/groff/tests/draw-ellipse.sh new file mode 100755 index 000000000..cf6839130 --- /dev/null +++ b/src/roff/groff/tests/draw-ellipse.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# +# Copyright (C) 2023 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/>. +# + +groff="${abs_top_builddir:-.}/test-groff" + +expected_line_1='t *A' +expected_line_2='D *e *10000 *24000' +expected_line_3='t *B' + +actual=$(printf 'A\\D@e 1 2@B\n' | "$groff" -Tps -Z) +echo "$actual" +# '/^t *A/{p;n;/^D *e/{p;n;/^t *B/p;}}' +actual=$(echo "$actual" \ + | sed -n -e '/^t *A/{' -e 'p;n;/^D *e/{' -e 'p;n;/^t *B/p;' -e '}' \ + -e '}') + +fail= + +echo "$actual" | sed -n '1p' | grep "$expected_line_1" || fail=yes +echo "$actual" | sed -n '2p' | grep "$expected_line_2" || fail=yes +echo "$actual" | sed -n '3p' | grep "$expected_line_3" || fail=yes + +test -z "$fail" diff --git a/src/roff/groff/tests/draw-filled-circle.sh b/src/roff/groff/tests/draw-filled-circle.sh new file mode 100755 index 000000000..ed0cf839a --- /dev/null +++ b/src/roff/groff/tests/draw-filled-circle.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# +# Copyright (C) 2023 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/>. +# + +groff="${abs_top_builddir:-.}/test-groff" + +expected_line_1='t *A' +expected_line_2='D *C *10000' +expected_line_3='t *B' + +actual=$(printf 'A\\D@C 1@B\n' | "$groff" -Tps -Z) +echo "$actual" +# '/^t *A/{p;n;/^D *C/{p;n;/^t *B/p;}}' +actual=$(echo "$actual" \ + | sed -n -e '/^t *A/{' -e 'p;n;/^D *C/{' -e 'p;n;/^t *B/p;' -e '}' \ + -e '}') + +fail= + +echo "$actual" | sed -n '1p' | grep "$expected_line_1" || fail=yes +echo "$actual" | sed -n '2p' | grep "$expected_line_2" || fail=yes +echo "$actual" | sed -n '3p' | grep "$expected_line_3" || fail=yes + +test -z "$fail" diff --git a/src/roff/groff/tests/draw-filled-ellipse.sh b/src/roff/groff/tests/draw-filled-ellipse.sh new file mode 100755 index 000000000..2d834d209 --- /dev/null +++ b/src/roff/groff/tests/draw-filled-ellipse.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# +# Copyright (C) 2023 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/>. +# + +groff="${abs_top_builddir:-.}/test-groff" + +expected_line_1='t *A' +expected_line_2='D *E *10000 *24000' +expected_line_3='t *B' + +actual=$(printf 'A\\D@E 1 2@B\n' | "$groff" -Tps -Z) +echo "$actual" +# '/^t *A/{p;n;/^D *E/{p;n;/^t *B/p;}}' +actual=$(echo "$actual" \ + | sed -n -e '/^t *A/{' -e 'p;n;/^D *E/{' -e 'p;n;/^t *B/p;' -e '}' \ + -e '}') + +fail= + +echo "$actual" | sed -n '1p' | grep "$expected_line_1" || fail=yes +echo "$actual" | sed -n '2p' | grep "$expected_line_2" || fail=yes +echo "$actual" | sed -n '3p' | grep "$expected_line_3" || fail=yes + +test -z "$fail" diff --git a/src/roff/groff/tests/draw-filled-polygon.sh b/src/roff/groff/tests/draw-filled-polygon.sh new file mode 100755 index 000000000..615a3dcfb --- /dev/null +++ b/src/roff/groff/tests/draw-filled-polygon.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# +# Copyright (C) 2023 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/>. +# + +groff="${abs_top_builddir:-.}/test-groff" + +expected_line_1='t *A' +expected_line_2='D *P *10000 *12000 *0 *-12000' +expected_line_3='t *B' + +actual=$(printf 'A\\D@P 1 1 0 -1@B\n' | "$groff" -Tps -Z) +echo "$actual" +# '/^t *A/{p;n;/^D *P/{p;n;/^t *B/p;}}' +actual=$(echo "$actual" \ + | sed -n -e '/^t *A/{' -e 'p;n;/^D *P/{' -e 'p;n;/^t *B/p;' -e '}' \ + -e '}') + +fail= + +echo "$actual" | sed -n '1p' | grep "$expected_line_1" || fail=yes +echo "$actual" | sed -n '2p' | grep "$expected_line_2" || fail=yes +echo "$actual" | sed -n '3p' | grep "$expected_line_3" || fail=yes + +test -z "$fail" diff --git a/src/roff/groff/tests/draw-line.sh b/src/roff/groff/tests/draw-line.sh new file mode 100755 index 000000000..1f809da18 --- /dev/null +++ b/src/roff/groff/tests/draw-line.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# +# Copyright (C) 2023 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/>. +# + +groff="${abs_top_builddir:-.}/test-groff" + +expected_line_1='t *A' +expected_line_2='D *l *10000 *12000' +expected_line_3='t *B' + +actual=$(printf 'A\\D@l 1 1@B\n' | "$groff" -Tps -Z) +echo "$actual" +# '/^t *A/{p;n;/^D *l/{p;n;/^t *B/p;}}' +actual=$(echo "$actual" \ + | sed -n -e '/^t *A/{' -e 'p;n;/^D *l/{' -e 'p;n;/^t *B/p;' -e '}' \ + -e '}') + +fail= + +echo "$actual" | sed -n '1p' | grep "$expected_line_1" || fail=yes +echo "$actual" | sed -n '2p' | grep "$expected_line_2" || fail=yes +echo "$actual" | sed -n '3p' | grep "$expected_line_3" || fail=yes + +test -z "$fail" diff --git a/src/roff/groff/tests/draw-polygon.sh b/src/roff/groff/tests/draw-polygon.sh new file mode 100755 index 000000000..a7406d941 --- /dev/null +++ b/src/roff/groff/tests/draw-polygon.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# +# Copyright (C) 2023 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/>. +# + +groff="${abs_top_builddir:-.}/test-groff" + +expected_line_1='t *A' +expected_line_2='D *p *10000 *12000 *0 *-12000' +expected_line_3='t *B' + +actual=$(printf 'A\\D@p 1 1 0 -1@B\n' | "$groff" -Tps -Z) +echo "$actual" +# '/^t *A/{p;n;/^D *p/{p;n;/^t *B/p;}}' +actual=$(echo "$actual" \ + | sed -n -e '/^t *A/{' -e 'p;n;/^D *p/{' -e 'p;n;/^t *B/p;' -e '}' \ + -e '}') + +fail= + +echo "$actual" | sed -n '1p' | grep "$expected_line_1" || fail=yes +echo "$actual" | sed -n '2p' | grep "$expected_line_2" || fail=yes +echo "$actual" | sed -n '3p' | grep "$expected_line_3" || fail=yes + +test -z "$fail" diff --git a/src/roff/groff/tests/draw-spline.sh b/src/roff/groff/tests/draw-spline.sh new file mode 100755 index 000000000..a8108012f --- /dev/null +++ b/src/roff/groff/tests/draw-spline.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# +# Copyright (C) 2023 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/>. +# + +groff="${abs_top_builddir:-.}/test-groff" + +expected_line_1='t *A' +expected_line_2='D *~ *10000 *12000' +expected_line_3='t *B' + +actual=$(printf 'A\\D@~ 1 1@B\n' | "$groff" -Tps -Z) +echo "$actual" +# '/^t *A/{p;n;/^D *~/{p;n;/^t *B/p;}}' +actual=$(echo "$actual" \ + | sed -n -e '/^t *A/{' -e 'p;n;/^D *~/{' -e 'p;n;/^t *B/p;' -e '}' \ + -e '}') + +fail= + +echo "$actual" | sed -n '1p' | grep "$expected_line_1" || fail=yes +echo "$actual" | sed -n '2p' | grep "$expected_line_2" || fail=yes +echo "$actual" | sed -n '3p' | grep "$expected_line_3" || fail=yes + +test -z "$fail" diff --git a/src/roff/groff/tests/set-stroke-thickness.sh b/src/roff/groff/tests/set-stroke-thickness.sh new file mode 100755 index 000000000..fe3b55dc8 --- /dev/null +++ b/src/roff/groff/tests/set-stroke-thickness.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# +# Copyright (C) 2023 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/>. +# + +groff="${abs_top_builddir:-.}/test-groff" + +expected_line_1='t *A' +expected_line_2='D *t *720' +expected_line_3='t *B' + +actual=$(printf 'A\\D@t 720@B\n' | "$groff" -Tps -Z) +echo "$actual" +# '/^t *A/{p;n;/^D *t/{p;n;/^t *B/p;}}' +actual=$(echo "$actual" \ + | sed -n -e '/^t *A/{' -e 'p;n;/^D *t/{' -e 'p;n;/^t *B/p;' -e '}' \ + -e '}') + +fail= + +echo "$actual" | sed -n '1p' | grep "$expected_line_1" || fail=yes +echo "$actual" | sed -n '2p' | grep "$expected_line_2" || fail=yes +echo "$actual" | sed -n '3p' | grep "$expected_line_3" || fail=yes + +test -z "$fail" _______________________________________________ Groff-commit mailing list Groff-commit@gnu.org https://lists.gnu.org/mailman/listinfo/groff-commit