diff options
| author | @amit.chandra <@amit.chandra> | 2019-04-26 19:53:18 +0530 |
|---|---|---|
| committer | wizAmit <amitforfriends_dns@yahoo.com> | 2019-05-14 12:26:25 +0530 |
| commit | 02a148dba261439626c5020a7cbb15e690521e87 (patch) | |
| tree | 8db4419ad473deefb1fcdb5eaea4d170dd0b8c3a /src/libcore/tests | |
| parent | 80e7cde2238e837a9d6a240af9a3253f469bb2cf (diff) | |
| download | rust-02a148dba261439626c5020a7cbb15e690521e87.tar.gz rust-02a148dba261439626c5020a7cbb15e690521e87.zip | |
wip nth_back on chunks
Signed-off-by: wizAmit <amitforfriends_dns@yahoo.com>
Diffstat (limited to 'src/libcore/tests')
| -rw-r--r-- | src/libcore/tests/slice.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/libcore/tests/slice.rs b/src/libcore/tests/slice.rs index acf6b03791f..0233b96d3a7 100644 --- a/src/libcore/tests/slice.rs +++ b/src/libcore/tests/slice.rs @@ -135,6 +135,19 @@ fn test_chunks_nth() { } #[test] +fn test_chunks_nth_back() { + let v: &[i32] = &[0, 1, 2, 3, 4, 5]; + let mut c = v.chunks(2); + assert_eq!(c.nth_back(1).unwrap(), &[2, 3]); + assert_eq!(c.next().unwrap(), &[4, 5]); + + let v2: &[i32] = &[0, 1, 2, 3, 4]; + let mut c2 = v2.chunks(3); + assert_eq!(c2.nth_back(1).unwrap(), &[0, 1]); + assert_eq!(c2.next(), None); +} + +#[test] fn test_chunks_last() { let v: &[i32] = &[0, 1, 2, 3, 4, 5]; let c = v.chunks(2); |
