]> git.lizzy.rs Git - rust.git/blobdiff - src/libcore/tests/slice.rs
wip nth_back on chunks
[rust.git] / src / libcore / tests / slice.rs
index acf6b03791f01ad27baed0bcc0ddef31e11985cc..0233b96d3a72d6d08c0f2bfbf29f3d58650489f0 100644 (file)
@@ -134,6 +134,19 @@ fn test_chunks_nth() {
     assert_eq!(c2.next(), None);
 }
 
+#[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];