extend the tests
This commit is contained in:
parent
628b2d05c9
commit
ed66afe4b4
21
src/lib.rs
21
src/lib.rs
|
|
@ -79,10 +79,10 @@ where
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
struct Small([u8; 48]);
|
struct Small([u32; 6]);
|
||||||
|
|
||||||
impl Iterator for Small {
|
impl Iterator for Small {
|
||||||
type Item = u8;
|
type Item = u32;
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
let ret = self.0.get(self.0[0] as usize).copied();
|
let ret = self.0.get(self.0[0] as usize).copied();
|
||||||
self.0[0] += 1;
|
self.0[0] += 1;
|
||||||
|
|
@ -92,16 +92,25 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn it_works() {
|
fn it_works() {
|
||||||
let mut it = Small([42; 48]);
|
let mut it = Small([0, 42, 13, 37, 29, 11]);
|
||||||
|
assert_eq!(it.next(), Some(0));
|
||||||
assert_eq!(it.next(), Some(42));
|
assert_eq!(it.next(), Some(42));
|
||||||
|
assert_eq!(it.next(), Some(13));
|
||||||
|
|
||||||
let mut it: Dyn<dyn Iterator<Item = u8>> = Small([42; 48]).into();
|
let mut it: Dyn<dyn Iterator<Item = u32>> = it.into();
|
||||||
assert_eq!(it.next(), Some(42));
|
assert_eq!(it.next(), Some(37));
|
||||||
|
assert_eq!(it.next(), Some(29));
|
||||||
|
assert_eq!(it.next(), Some(11));
|
||||||
|
assert_eq!(it.next(), None);
|
||||||
|
assert_eq!(it.next(), None);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn vec() {
|
fn vec() {
|
||||||
let mut it: Dyn<dyn Iterator<Item = u8>> = vec![42; 48].into_iter().into();
|
let mut it: Dyn<dyn Iterator<Item = u8>> = vec![42, 13, 37].into_iter().into();
|
||||||
assert_eq!(it.next(), Some(42));
|
assert_eq!(it.next(), Some(42));
|
||||||
|
assert_eq!(it.next(), Some(13));
|
||||||
|
assert_eq!(it.next(), Some(37));
|
||||||
|
assert_eq!(it.next(), None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user