summaryrefslogtreecommitdiff
path: root/tests/lib/libcurses
diff options
context:
space:
mode:
authorrillig <rillig@NetBSD.org>2021-02-07 23:30:33 +0000
committerrillig <rillig@NetBSD.org>2021-02-07 23:30:33 +0000
commitf8a2c64671dbac866ba0cb737ea4146f0ae5ce29 (patch)
treed627de6169b7b60dcbbccf87f5645a03d8009519 /tests/lib/libcurses
parent52d6706fd3f9d6f58ae2baf0167becd13800188d (diff)
tests/libcurses: fix undefined behavior in test addch
The libcurses framework is not strictly typed and thus provides plenty of ways to shoot yourself in the foot. It's a waste of time debugging things that a proper programming language can easily prevent. The function addch expects an argument of type 'chtype'. Passing a "double-quoted" string does not match this, as 'chtype' is completely different from a plain 'char'. Instead, functions taking a 'chtype' must be passed a `backtick-quoted` string.
Diffstat (limited to 'tests/lib/libcurses')
-rw-r--r--tests/lib/libcurses/tests/addch17
1 files changed, 8 insertions, 9 deletions
diff --git a/tests/lib/libcurses/tests/addch b/tests/lib/libcurses/tests/addch
index 96121392437..a3edefe1632 100644
--- a/tests/lib/libcurses/tests/addch
+++ b/tests/lib/libcurses/tests/addch
@@ -3,23 +3,22 @@ call OK addch `\001t`
call OK refresh
call OK mvaddch 5 3 `\003e`
call OK refresh
-call OK addch "\n"
+call OK addch `\000\n`
# Somewhere between NetBSD 8.0 and 9.0, a bug was added to addch that
# doubled the spaces for a tab. Instead of 8 spaces, there are now 16.
-call OK addch "\t"
+call OK addch `\000\t`
call2 6 16 getyx STDSCR # FIXME: must be 8, not 16
-call OK addch "8"
-call OK addch "\n"
+call OK addch `\0008`
+call OK addch `\000\n`
# Somewhere between NetBSD 8.0 and 9.0, a bug was added to addch that
# doubled the spaces for a tab. Instead of 1 space, there are now 2.
call OK addstr "0123456"
-call OK addch "\t"
-call2 7 9 getyx STDSCR # FIXME: with probability around 50%, the
- # 7 comes out as a 6.
-call OK addch "8"
-call OK addch "\n"
+call OK addch `\000\t`
+call2 7 9 getyx STDSCR
+call OK addch `\0008`
+call OK addch `\000\n`
call OK refresh
compare addch.chk