1 | #![allow (clippy::reversed_empty_ranges)] // This is intentional. |
2 | |
3 | use futures::io::Window; |
4 | |
5 | #[test] |
6 | fn set() { |
7 | let mut buffer = Window::new(&[1, 2, 3]); |
8 | buffer.set(..3); |
9 | assert_eq!(buffer.as_ref(), &[1, 2, 3]); |
10 | buffer.set(3..3); |
11 | assert_eq!(buffer.as_ref(), &[]); |
12 | buffer.set(3..=2); // == 3..3 |
13 | assert_eq!(buffer.as_ref(), &[]); |
14 | buffer.set(0..2); |
15 | assert_eq!(buffer.as_ref(), &[1, 2]); |
16 | } |
17 | |
18 | #[test] |
19 | #[should_panic ] |
20 | fn set_panic_out_of_bounds() { |
21 | let mut buffer = Window::new(&[1, 2, 3]); |
22 | buffer.set(2..4); |
23 | } |
24 | |
25 | #[test] |
26 | #[should_panic ] |
27 | fn set_panic_start_is_greater_than_end() { |
28 | let mut buffer = Window::new(&[1, 2, 3]); |
29 | buffer.set(3..2); |
30 | } |
31 | |