From 32b1d721706a8b42d900969679f2fc59d99a371b Mon Sep 17 00:00:00 2001 From: Adam Saponara Date: Sun, 28 Nov 2021 13:24:07 -0500 Subject: [PATCH] add test case for `tb_printf_ex` --- tests/run.sh | 11 +++++++++++ tests/test_basic/expected.ansi | 2 +- tests/test_basic/test.php | 5 ++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/run.sh b/tests/run.sh index f674d29..367b64b 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -11,6 +11,8 @@ main() { local xterm_fg='grey93' local main_ec=0 + check_deps + # loop through each 'test_*' dir for test_php in $(find . -type f -wholename '*/test_*/test.php'); do local test_dir=$(dirname $test_php) @@ -123,4 +125,13 @@ main() { return $main_ec } +check_deps() { + for dep in Xvfb xterm xvkbd; do + if ! command -v $dep &>/dev/null; then + echo "Missing dependency: $dep" + exit 1 + fi + done +} + main diff --git a/tests/test_basic/expected.ansi b/tests/test_basic/expected.ansi index 3cf5db9..7666d00 100644 --- a/tests/test_basic/expected.ansi +++ b/tests/test_basic/expected.ansi @@ -1,7 +1,7 @@ #5width=80 #5height=24 #5event rv=0 type=1 mod=2 key=1 ch=0 w=0 h=0 x=0 y=0 - +#5out_w=50 diff --git a/tests/test_basic/test.php b/tests/test_basic/test.php index 580b9c5..3d22205 100755 --- a/tests/test_basic/test.php +++ b/tests/test_basic/test.php @@ -19,7 +19,8 @@ $test->xvkbd('\Ca'); // Ctrl-A $event = $test->ffi->new('struct tb_event'); $rv = $test->ffi->tb_peek_event(FFI::addr($event), 1000); -$test->ffi->tb_printf(0, 2, $blue, $bg, "event rv=%d type=%d mod=%d key=%d ch=%d w=%d h=%d x=%d y=%d", +$out_w = $test->ffi->new('size_t'); +$test->ffi->tb_printf_ex(0, 2, $blue, $bg, FFI::addr($out_w), "event rv=%d type=%d mod=%d key=%d ch=%d w=%d h=%d x=%d y=%d", $rv, $event->type, $event->mod, @@ -31,6 +32,8 @@ $test->ffi->tb_printf(0, 2, $blue, $bg, "event rv=%d type=%d mod=%d key=%d ch=%d $event->y ); +$test->ffi->tb_printf(0, 3, 0, 0, "out_w=%d", $out_w->cdata); + $test->ffi->tb_present(); $test->screencap(); -- 2.39.5