|
1 | 1 | use crate::io::prelude::*;
|
2 |
| -use crate::io::{copy, empty, repeat, sink, Empty, Repeat, Sink}; |
| 2 | +use crate::io::{copy, empty, repeat, sink, Empty, Repeat, SeekFrom, Sink}; |
3 | 3 |
|
4 | 4 | #[test]
|
5 | 5 | fn copy_copies() {
|
@@ -29,6 +29,26 @@ fn empty_reads() {
|
29 | 29 | assert_eq!(e.by_ref().read(&mut [0; 1024]).unwrap(), 0);
|
30 | 30 | }
|
31 | 31 |
|
| 32 | +#[test] |
| 33 | +fn empty_seeks() { |
| 34 | + let mut e = empty(); |
| 35 | + assert!(matches!(e.seek(SeekFrom::Start(0)), Ok(0))); |
| 36 | + assert!(matches!(e.seek(SeekFrom::Start(1)), Ok(0))); |
| 37 | + assert!(matches!(e.seek(SeekFrom::Start(u64::MAX)), Ok(0))); |
| 38 | + |
| 39 | + assert!(matches!(e.seek(SeekFrom::End(i64::MIN)), Ok(0))); |
| 40 | + assert!(matches!(e.seek(SeekFrom::End(-1)), Ok(0))); |
| 41 | + assert!(matches!(e.seek(SeekFrom::End(0)), Ok(0))); |
| 42 | + assert!(matches!(e.seek(SeekFrom::End(1)), Ok(0))); |
| 43 | + assert!(matches!(e.seek(SeekFrom::End(i64::MAX)), Ok(0))); |
| 44 | + |
| 45 | + assert!(matches!(e.seek(SeekFrom::Current(i64::MIN)), Ok(0))); |
| 46 | + assert!(matches!(e.seek(SeekFrom::Current(-1)), Ok(0))); |
| 47 | + assert!(matches!(e.seek(SeekFrom::Current(0)), Ok(0))); |
| 48 | + assert!(matches!(e.seek(SeekFrom::Current(1)), Ok(0))); |
| 49 | + assert!(matches!(e.seek(SeekFrom::Current(i64::MAX)), Ok(0))); |
| 50 | +} |
| 51 | + |
32 | 52 | #[test]
|
33 | 53 | fn repeat_repeats() {
|
34 | 54 | let mut r = repeat(4);
|
|
0 commit comments