commit:     de41ef45b33e645d04756c3a7dba2230f847eb0f
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Fri Jun  9 22:10:04 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Jun  9 22:25:47 2023 +0000
URL:        
https://gitweb.gentoo.org/proj/gentoo-functions.git/commit/?id=de41ef45

test-functions: Add a test for the _update_cursor_coords() function

Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>

 test-functions | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/test-functions b/test-functions
index 0fd998d..9f87e98 100755
--- a/test-functions
+++ b/test-functions
@@ -303,6 +303,27 @@ test_is_visible() {
                iterate_tests 2 "$@"
 }
 
+test_update_cursor_coords() {
+       if _has_dumb_terminal; then
+               printf '1..0 # TERM defines the terminal as being dumb\n'
+       elif ! ctty=$(ps -p "$$" -otty= 2>/dev/null) || [ -z "${ctty}" ]; then
+               printf '1..0 # the ps(1) implementation is defective or 
non-compliant\n'
+       elif [ "${ctty}" = "?" ]; then
+               printf '1..0 # no controlling terminal is available\n'
+       elif [ ! -e /dev/tty ]; then
+               printf '1..0 # the /dev/tty character device is missing\n'
+       elif ! _update_winsize </dev/tty; then
+               printf '1..0 # the controlling terminal is not smart\n'
+       elif ! _update_cursor_coords <>/dev/tty; then
+               printf '1..1\n'
+               printf 'not ok 1 - ecm48-cpr failed\n'
+               false
+       else
+               printf '1..1\n'
+               printf 'ok 1 - ecm48-cpr succeeded (x = %d, y = %d)\n' 
"${genfun_x}" "${genfun_y}"
+       fi
+}
+
 test_yesno() {
        set -- \
                0  yes \
@@ -430,6 +451,7 @@ test_esyslog || rc=1
 test_is_identifier || rc=1
 test_is_int || rc=1
 test_is_visible || rc=1
+test_update_cursor_coords || rc=1
 test_yesno || rc=1
 cleanup_tmpdir
 exit "${rc}"

Reply via email to