mirror of
https://github.com/sharkdp/bat.git
synced 2024-11-08 00:44:30 +01:00
Add unit test for InputFileReader
This commit is contained in:
parent
e09d7dabb8
commit
078228deac
@ -45,3 +45,30 @@ impl<'a> InputFile<'a> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn basic() {
|
||||
let content = b"hello\nworld";
|
||||
let mut reader = InputFileReader::new(&content[..]);
|
||||
|
||||
let mut buffer = vec![];
|
||||
|
||||
let res = reader.read_line(&mut buffer);
|
||||
assert!(res.is_ok());
|
||||
assert_eq!(true, res.unwrap());
|
||||
assert_eq!(b"hello\n", &buffer[..]);
|
||||
|
||||
buffer.clear();
|
||||
|
||||
let res = reader.read_line(&mut buffer);
|
||||
assert!(res.is_ok());
|
||||
assert_eq!(true, res.unwrap());
|
||||
assert_eq!(b"world", &buffer[..]);
|
||||
|
||||
buffer.clear();
|
||||
|
||||
let res = reader.read_line(&mut buffer);
|
||||
assert!(res.is_ok());
|
||||
assert_eq!(false, res.unwrap());
|
||||
assert!(buffer.is_empty());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user