From 38927e0a3e5c258e3eb016242a51e2cb93a2e0dc Mon Sep 17 00:00:00 2001 From: Leroy Hopson Date: Sun, 26 Jun 2022 15:00:36 +0700 Subject: [PATCH] Fix winsize test to support unsigned short The type of winsize.ws_col and winsize.ws_row is unsigned short, so change python's struct.unpack format from 'hh' (short) to 'HH'. Otherwise, we can only test sizes up to 32767 when actually sizes up to 65535 are supported. --- test/platform/unix/unix.test.gd | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/test/platform/unix/unix.test.gd b/test/platform/unix/unix.test.gd index c688b2d..71500d6 100644 --- a/test/platform/unix/unix.test.gd +++ b/test/platform/unix/unix.test.gd @@ -54,6 +54,15 @@ func test_open_pty_has_correct_win_size(): assert_eq(winsize.rows, rows) +func test_win_size_supports_max_unsigned_short_value(): + var cols = 65535 + var rows = 65535 + var result = pty.open(cols, rows) + var winsize = helper._get_winsize(result[1].master) + assert_eq(winsize.cols, cols) + assert_eq(winsize.cols, rows) + + func test_closes_pty_on_exit(): var num_pts = helper._get_pts().size() pty.fork("sleep", ["1000"]) @@ -83,7 +92,7 @@ class Helper: [ "-c", ( - "import struct, fcntl, termios; print(struct.unpack('hh', fcntl.ioctl(%d, termios.TIOCGWINSZ, '1234')))" + "import struct, fcntl, termios; print(struct.unpack('HH', fcntl.ioctl(%d, termios.TIOCGWINSZ, '1234')))" % fd ) ],