modes:pair:tests: refactor using new Card/PlayingCard methods

This commit is contained in:
2026-04-05 04:39:02 +01:00
committed by oreodave
parent f1d6b36cd9
commit 072159399d

View File

@@ -97,10 +97,7 @@ impl PartialOrd for Pair {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::{ use crate::{card::Rank, modes::tests::test_footstool};
card::{make_decks, Rank},
modes::tests::test_footstool,
};
#[test] #[test]
fn new() { fn new() {
@@ -137,7 +134,7 @@ mod tests {
}); });
// TEST: Improper pair tests. // TEST: Improper pair tests.
PlayingCard::iter_deck(1) PlayingCard::iter_all(1)
.map(Card::PlayingCard) .map(Card::PlayingCard)
.map(|c1| { .map(|c1| {
// TEST: Any card with one joker can be made into a valid pair. // TEST: Any card with one joker can be made into a valid pair.
@@ -169,7 +166,7 @@ mod tests {
}); });
// TEST: Proper pair tests // TEST: Proper pair tests
PlayingCard::iter_deck(1) PlayingCard::iter_all(1)
.map(Card::PlayingCard) .map(Card::PlayingCard)
// Flat Map every card (c1) into combinations (c1, card of same rank as c1) // Flat Map every card (c1) into combinations (c1, card of same rank as c1)
.flat_map(|c1| c1.rank().unwrap().cards().map(move |c2| (c1, c2))) .flat_map(|c1| c1.rank().unwrap().cards().map(move |c2| (c1, c2)))
@@ -198,8 +195,8 @@ mod tests {
/** Create an exhaustive set of pairs for one deck. */ /** Create an exhaustive set of pairs for one deck. */
fn exhaustive_pairs_deck() -> impl Iterator<Item = Pair> { fn exhaustive_pairs_deck() -> impl Iterator<Item = Pair> {
make_decks(1).flat_map(|c1| { Card::iter_all(1).flat_map(|c1| {
make_decks(1).filter_map(move |c2| Pair::new(c1, c2)) Card::iter_all(1).filter_map(move |c2| Pair::new(c1, c2))
}) })
} }