Skip to content

Commit

Permalink
Test RepeatN::peeking_next
Browse files Browse the repository at this point in the history
  • Loading branch information
Philippe-Cholet committed Jan 18, 2024
1 parent 272aa21 commit 1714cc0
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/test_std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::it::izip;
use crate::it::multipeek;
use crate::it::multizip;
use crate::it::peek_nth;
use crate::it::repeat_n;
use crate::it::ExactlyOneError;
use crate::it::FoldWhile;
use crate::it::Itertools;
Expand Down Expand Up @@ -674,6 +675,21 @@ fn test_multipeek_peeking_next() {
assert_eq!(mp.peek(), None);
}

#[test]
fn test_repeat_n_peeking_next() {
use crate::it::PeekingNext;
let mut rn = repeat_n(0, 5);
assert_eq!(rn.peeking_next(|&x| x != 0), None);
assert_eq!(rn.peeking_next(|&x| x <= 0), Some(0));
assert_eq!(rn.next(), Some(0));
assert_eq!(rn.peeking_next(|&x| x <= 0), Some(0));
assert_eq!(rn.peeking_next(|&x| x != 0), None);
assert_eq!(rn.peeking_next(|&x| x >= 0), Some(0));
assert_eq!(rn.next(), Some(0));
assert_eq!(rn.peeking_next(|&x| x <= 0), None);
assert_eq!(rn.next(), None);
}

#[test]
fn test_peek_nth() {
let nums = vec![1u8, 2, 3, 4, 5];
Expand Down

0 comments on commit 1714cc0

Please sign in to comment.