Kings-Eunuch/kings-eunuch/tests/straight_flush_tests.rs
2026-02-08 09:13:01 -05:00

76 lines
2.2 KiB
Rust

use kings_eunuch::hand_building::{find_straight_flush, Card};
#[test]
fn test_straight_flush_basic() {
let sf_basic: Vec<Card> = ["9h", "8h", "7h", "6h", "5h"]
.iter()
.map(|s| Card::str_to_card(s).unwrap())
.collect();
let cards = find_straight_flush(&sf_basic).expect("Should find straight flush");
assert_eq!(cards.len(), 5, "Straight flush should have 5 cards");
}
#[test]
fn test_royal_flush() {
let royal: Vec<Card> = ["Ah", "Kh", "Qh", "Jh", "Th"]
.iter()
.map(|s| Card::str_to_card(s).unwrap())
.collect();
let cards = find_straight_flush(&royal).expect("Should find royal flush");
assert_eq!(cards.len(), 5);
}
#[test]
fn test_straight_flush_from_7_cards() {
let sf_7cards: Vec<Card> = ["9s", "8s", "7s", "6s", "5s", "Kd", "2c"]
.iter()
.map(|s| Card::str_to_card(s).unwrap())
.collect();
let cards = find_straight_flush(&sf_7cards).expect("Should find straight flush from 7 cards");
assert_eq!(cards.len(), 5);
}
#[test]
fn test_wheel_straight_flush() {
let wheel_sf: Vec<Card> = ["Ad", "2d", "3d", "4d", "5d"]
.iter()
.map(|s| Card::str_to_card(s).unwrap())
.collect();
let cards = find_straight_flush(&wheel_sf).expect("Should find wheel straight flush");
assert_eq!(cards.len(), 5);
}
#[test]
fn test_flush_but_not_straight() {
let flush_only: Vec<Card> = ["Ac", "Kc", "Qc", "Jc", "9c"]
.iter()
.map(|s| Card::str_to_card(s).unwrap())
.collect();
assert!(find_straight_flush(&flush_only).is_none(), "Flush without straight should not match");
}
#[test]
fn test_straight_but_not_flush() {
let straight_only: Vec<Card> = ["9h", "8d", "7s", "6c", "5h"]
.iter()
.map(|s| Card::str_to_card(s).unwrap())
.collect();
assert!(find_straight_flush(&straight_only).is_none(), "Straight without flush should not match");
}
#[test]
fn test_no_straight_flush() {
let no_sf: Vec<Card> = ["Ah", "Ks", "Qd", "Jc", "9h"]
.iter()
.map(|s| Card::str_to_card(s).unwrap())
.collect();
assert!(find_straight_flush(&no_sf).is_none(), "No straight flush in random cards");
}