Add tests to 'terminal_size'

This commit is contained in:
Ticki 2016-03-09 19:17:00 +01:00
parent 5d4826d4ff
commit 08746c0d2a
4 changed files with 15 additions and 4 deletions

View File

@ -24,6 +24,7 @@ Features
- Redox support.
- 256-color mode.
- Panic-free error handling.
- Special keys events.
and much more.

View File

@ -101,11 +101,11 @@ impl<R: Read> TermRead for R {
#[cfg(test)]
mod test {
use super::*;
#[cfg(feature = "nightly")]
#[test]
fn test_keys() {
use {TermRead, Key};
let mut i = b"\x1Bayo\x7F\x1B[D".keys();
assert_eq!(i.next(), Some(Key::Alt('a')));

View File

@ -57,3 +57,13 @@ pub fn terminal_size() -> Result<(usize, usize), TerminalError> {
Ok((try!(w), try!(h)))
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn test_size() {
assert!(terminal_size().is_ok());
}
}

View File

@ -7,8 +7,8 @@ pub const TIOCGWINSZ: usize = 0x00005413;
pub const TIOCGWINSZ: usize = 0x40087468;
extern {
pub fn tcgetattr(filedes: c_int, termptr: *mut Termios) -> c_int;
pub fn tcsetattr(filedes: c_int, opt: c_int, termptr: *mut Termios) -> c_int;
pub fn tcgetattr(fd: c_int, termptr: *mut Termios) -> c_int;
pub fn tcsetattr(fd: c_int, opt: c_int, termptr: *mut Termios) -> c_int;
pub fn cfmakeraw(termptr: *mut Termios);
}