This commit is contained in:
Артём Павлов [Artyom Pavlov] 2018-11-18 23:14:52 +03:00
parent 126b71f690
commit 6ad61b9c3b
No known key found for this signature in database
GPG Key ID: 13A9399FB77E335C

View File

@ -1621,6 +1621,16 @@ fn test_range_step() {
#[test] #[test]
fn test_step_by_skip() { fn test_step_by_skip() {
assert_eq!((0..640).step_by(128).skip(1).collect::<Vec<_>>(), [128, 256, 384, 512]); assert_eq!((0..640).step_by(128).skip(1).collect::<Vec<_>>(), [128, 256, 384, 512]);
assert_eq!((0..=50).step_by(10).nth(3), Some(30));
assert_eq!((250..=255u8).step_by(10).nth(3), Some(230));
}
#[test]
fn test_range_inclusive_step() {
assert_eq!((0..=50).step_by(10).collect::<Vec<_>>(), [0, 10, 20, 30, 40, 50]);
assert_eq!((0..=5).step_by(1).collect::<Vec<_>>(), [0, 1, 2, 3, 4, 5]);
assert_eq!((200..=255u8).step_by(10).collect::<Vec<_>>(), [200, 210, 220, 230, 240, 250]);
assert_eq!((250..=255u8).step_by(1).collect::<Vec<_>>(), [250, 251, 252, 253, 254, 255]);
} }
#[test] #[test]