From ea49849b0635462c7029b5df51476ef5b710b126 Mon Sep 17 00:00:00 2001 From: Severen Redwood Date: Fri, 26 Aug 2016 20:39:11 +1200 Subject: [PATCH] Improve the tests for tutil::screen::unix --- src/screen/unix.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/screen/unix.rs b/src/screen/unix.rs index 7e27336..087782e 100644 --- a/src/screen/unix.rs +++ b/src/screen/unix.rs @@ -112,6 +112,10 @@ mod test { if let Some((Width(width), Height(height))) = size() { assert_eq!(width, cols); assert_eq!(height, rows); + } else { + // If the terminal size cannot be found, than stty must not be able to find it either. + assert_eq!(cols, 0); + assert_eq!(rows, 0); } } @@ -123,9 +127,12 @@ mod test { let cols = u16::from_str_radix(stdout.split_whitespace().last().unwrap(), 10).unwrap(); - if let Some((Width(width), Height(_))) = size() { + if let Some(Width(width)) = width() { assert_eq!(width, cols); - } + } else { + // If the terminal size cannot be found, than stty must not be able to find it either. + assert_eq!(cols, 0); + }; } #[test] @@ -136,8 +143,11 @@ mod test { let rows = u16::from_str_radix(stdout.split_whitespace().next().unwrap(), 10).unwrap(); - if let Some((Width(_), Height(height))) = size() { + if let Some(Height(height)) = height() { assert_eq!(height, rows); - } + } else { + // If the terminal size cannot be found, than stty must not be able to find it either. + assert_eq!(rows, 0); + }; } } -- 2.11.4.GIT