Add tests to 'terminal_size'
This commit is contained in:
parent
5d4826d4ff
commit
08746c0d2a
|
@ -24,6 +24,7 @@ Features
|
||||||
- Redox support.
|
- Redox support.
|
||||||
- 256-color mode.
|
- 256-color mode.
|
||||||
- Panic-free error handling.
|
- Panic-free error handling.
|
||||||
|
- Special keys events.
|
||||||
|
|
||||||
and much more.
|
and much more.
|
||||||
|
|
||||||
|
|
|
@ -101,11 +101,11 @@ impl<R: Read> TermRead for R {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[cfg(feature = "nightly")]
|
#[cfg(feature = "nightly")]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_keys() {
|
fn test_keys() {
|
||||||
|
use {TermRead, Key};
|
||||||
|
|
||||||
let mut i = b"\x1Bayo\x7F\x1B[D".keys();
|
let mut i = b"\x1Bayo\x7F\x1B[D".keys();
|
||||||
|
|
||||||
assert_eq!(i.next(), Some(Key::Alt('a')));
|
assert_eq!(i.next(), Some(Key::Alt('a')));
|
||||||
|
|
10
src/size.rs
10
src/size.rs
|
@ -57,3 +57,13 @@ pub fn terminal_size() -> Result<(usize, usize), TerminalError> {
|
||||||
|
|
||||||
Ok((try!(w), try!(h)))
|
Ok((try!(w), try!(h)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_size() {
|
||||||
|
assert!(terminal_size().is_ok());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -7,8 +7,8 @@ pub const TIOCGWINSZ: usize = 0x00005413;
|
||||||
pub const TIOCGWINSZ: usize = 0x40087468;
|
pub const TIOCGWINSZ: usize = 0x40087468;
|
||||||
|
|
||||||
extern {
|
extern {
|
||||||
pub fn tcgetattr(filedes: c_int, termptr: *mut Termios) -> c_int;
|
pub fn tcgetattr(fd: c_int, termptr: *mut Termios) -> c_int;
|
||||||
pub fn tcsetattr(filedes: c_int, opt: 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);
|
pub fn cfmakeraw(termptr: *mut Termios);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue