Skip to content

Commit

Permalink
more-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pragmaxim committed Jul 1, 2024
1 parent 57cc0d7 commit 0cc5f33
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,32 @@ mod tests {
assert_eq!(batches[2], vec![vec!['g', 'h', 'i', 'j']]);
}

#[tokio::test]
async fn test_min_size_of_vectors() {
let batches: Vec<Vec<Vec<char>>> = stream::iter(1..=10_005)
.map(|_| (0..10).map(|_| 'a').collect::<Vec<char>>())
.min_batch(100_000, |xs: &Vec<char>| xs.len())
.collect()
.await;

// Verify the batches
assert!(
batches.len() == 2,
"Expected batches length should not be {}",
batches.len()
);
assert!(
batches[0].len() == 10_000,
"Expected betch length should not be {}",
batches[0].len()
);
assert!(
batches[1].len() == 5,
"Expected betch length should not be {}",
batches[1].len()
);
}

#[derive(Debug, PartialEq, Eq)]
struct BlockOfTxs {
name: char,
Expand Down

0 comments on commit 0cc5f33

Please sign in to comment.