diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-07-28 03:01:44 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-07-28 03:01:44 +0200 |
| commit | cb8b491a65d93fd08752347d6a237457830567fa (patch) | |
| tree | b34eead0b826cabfc80c556c66f16849af6b82ad /src/libcore/tests | |
| parent | ece18b750db8e4c46a42d9a7ba6621a4800e9eae (diff) | |
| parent | b95bde44913852685b350d468d000453ece9696f (diff) | |
Rollup merge of #62074 - wizAmit:feature/mut_chunks_nth_back, r=scottmcm
squash of all commits for nth_back on ChunksMut wip nth_back for chunks_mut working chunksmut fixed nth_back for chunksmut Signed-off-by: wizAmit <amitforfriends_dns@yahoo.com> r? @timvermeulen r? @scottmcm
Diffstat (limited to 'src/libcore/tests')
| -rw-r--r-- | src/libcore/tests/slice.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/libcore/tests/slice.rs b/src/libcore/tests/slice.rs index 42ec9d451f7..b046c3ce5ce 100644 --- a/src/libcore/tests/slice.rs +++ b/src/libcore/tests/slice.rs @@ -223,6 +223,28 @@ fn test_chunks_mut_nth() { } #[test] +fn test_chunks_mut_nth_back() { + let v: &mut [i32] = &mut [0, 1, 2, 3, 4, 5]; + let mut c = v.chunks_mut(2); + assert_eq!(c.nth_back(1).unwrap(), &[2, 3]); + assert_eq!(c.next().unwrap(), &[0, 1]); + + let v1: &mut [i32] = &mut [0, 1, 2, 3, 4]; + let mut c1 = v1.chunks_mut(3); + assert_eq!(c1.nth_back(1).unwrap(), &[0, 1, 2]); + assert_eq!(c1.next(), None); + + let v3: &mut [i32] = &mut [0, 1, 2, 3, 4]; + let mut c3 = v3.chunks_mut(10); + assert_eq!(c3.nth_back(0).unwrap(), &[0, 1, 2, 3, 4]); + assert_eq!(c3.next(), None); + + let v4: &mut [i32] = &mut [0, 1, 2]; + let mut c4 = v4.chunks_mut(10); + assert_eq!(c4.nth_back(1_000_000_000usize), None); +} + +#[test] fn test_chunks_mut_last() { let v: &mut [i32] = &mut [0, 1, 2, 3, 4, 5]; let c = v.chunks_mut(2); |
