diff options
author | Nora <nora.widdecke@tu-bs.de> | 2019-01-22 20:57:34 +0100 |
---|---|---|
committer | Nora <nora.widdecke@tu-bs.de> | 2019-01-22 20:57:34 +0100 |
commit | fdcfacf7183dd5460ac265060f7c626e303e1a08 (patch) | |
tree | 2acd513fa90d11b9bd6e37752bfaad7657dd716f | |
parent | 489ec195efefb58f2a1ee4779ff1ebead4f3fc33 (diff) |
input: add test
-rw-r--r-- | src/input.rs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/input.rs b/src/input.rs index 860db05..07683b5 100644 --- a/src/input.rs +++ b/src/input.rs @@ -24,7 +24,7 @@ pub fn default_input_khline() -> io::Result<KhLine> { let lines = stdioutils::read_lines_from_stdin()?; if lines.len() > 1 { - Err(io::Error::new(io::ErrorKind::Other, "too many lines in cursorfile")) + Err(io::Error::new(io::ErrorKind::Other, "too many lines in input")) } else { lines[0].parse::<KhLine>().map_err(|err| io::Error::new(io::ErrorKind::Other, err.to_string())) } @@ -32,3 +32,17 @@ pub fn default_input_khline() -> io::Result<KhLine> { cursorfile::read_cursorfile() } } + +#[cfg(test)] +mod tests { + use super::*; + + use utils::stdioutils; + + #[test] + fn test_default_input_khline() { + stdioutils::test_stdin_write("a\nb\n"); + + assert!( default_input_khline().is_err()); + } +} |