add test for vec::IntoIter::next_chunk() impl

an adaption of the default impl's doctest
This commit is contained in:
The 8472 2022-07-26 21:28:14 +02:00
parent 2f9f2e507e
commit 4ba7cac359
2 changed files with 11 additions and 0 deletions

View file

@ -29,6 +29,7 @@
#![feature(binary_heap_as_slice)]
#![feature(inplace_iteration)]
#![feature(iter_advance_by)]
#![feature(iter_next_chunk)]
#![feature(round_char_boundary)]
#![feature(slice_group_by)]
#![feature(slice_partition_dedup)]

View file

@ -1,4 +1,5 @@
use core::alloc::{Allocator, Layout};
use core::iter::IntoIterator;
use core::ptr::NonNull;
use std::alloc::System;
use std::assert_matches::assert_matches;
@ -930,6 +931,15 @@ fn test_into_iter_count() {
assert_eq!([1, 2, 3].into_iter().count(), 3);
}
#[test]
fn test_into_iter_next_chunk() {
let mut iter = b"lorem".to_vec().into_iter();
assert_eq!(iter.next_chunk().unwrap(), [b'l', b'o']); // N is inferred as 2
assert_eq!(iter.next_chunk().unwrap(), [b'r', b'e', b'm']); // N is inferred as 3
assert_eq!(iter.next_chunk::<4>().unwrap_err().as_slice(), &[]); // N is explicitly 4
}
#[test]
fn test_into_iter_clone() {
fn iter_equal<I: Iterator<Item = i32>>(it: I, slice: &[i32]) {