diff options
| author | @amit.chandra <@amit.chandra> | 2019-06-22 22:59:24 +0530 |
|---|---|---|
| committer | wizAmit <amitforfriends_dns@yahoo.com> | 2019-06-23 02:02:21 +0530 |
| commit | 45832383af02a377877c2701d90dbe29883532a2 (patch) | |
| tree | dc9c49ace64365a769508ea2ad22b38afa5cbae2 /src/libcore/tests | |
| parent | 4a365a29d64bec75d107214319a129ba68fc12a3 (diff) | |
| download | rust-45832383af02a377877c2701d90dbe29883532a2.tar.gz rust-45832383af02a377877c2701d90dbe29883532a2.zip | |
squash commit for nth_back on chunks exact
wip nth_back for chunks_exact working nth_back for chunks exact Signed-off-by: wizAmit <amitforfriends_dns@yahoo.com>
Diffstat (limited to 'src/libcore/tests')
| -rw-r--r-- | src/libcore/tests/slice.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/libcore/tests/slice.rs b/src/libcore/tests/slice.rs index 03e65d2fe0b..13b02c71842 100644 --- a/src/libcore/tests/slice.rs +++ b/src/libcore/tests/slice.rs @@ -276,6 +276,25 @@ fn test_chunks_exact_nth() { } #[test] +fn test_chunks_exact_nth_back() { + let v: &[i32] = &[0, 1, 2, 3, 4, 5]; + let mut c = v.chunks_exact(2); + assert_eq!(c.nth_back(1).unwrap(), &[2, 3]); + assert_eq!(c.next().unwrap(), &[0, 1]); + assert_eq!(c.next(), None); + + let v2: &[i32] = &[0, 1, 2, 3, 4]; + let mut c2 = v2.chunks_exact(3); + assert_eq!(c2.nth_back(0).unwrap(), &[0, 1, 2]); + assert_eq!(c2.next(), None); + assert_eq!(c2.next_back(), None); + + let v3: &[i32] = &[0, 1, 2, 3, 4]; + let mut c3 = v3.chunks_exact(10); + assert_eq!(c3.nth_back(0), None); +} + +#[test] fn test_chunks_exact_last() { let v: &[i32] = &[0, 1, 2, 3, 4, 5]; let c = v.chunks_exact(2); |
