From 1714cc0d480c7a936e74f69cc8804041a31c5c24 Mon Sep 17 00:00:00 2001 From: Philippe-Cholet Date: Thu, 18 Jan 2024 11:54:02 +0100 Subject: [PATCH] Test `RepeatN::peeking_next` --- tests/test_std.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/test_std.rs b/tests/test_std.rs index be163e98d..5d2864573 100644 --- a/tests/test_std.rs +++ b/tests/test_std.rs @@ -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; @@ -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];