pub mod cards;
pub mod hand;
#[cfg(test)]
mod tests {
use std::time::Instant;
use crate::hand;
use crate::hand::Hand;
use crate::cards;
use crate::cards::Card;
use crate::cards::Suit;
use crate::cards::Value;
#[test]
fn full_hand() {
print_hand(&hand::Hand::full_deck() )
}
#[test]
fn stack_top() {
let bottom = Hand::from(
vec![
Card::new(Value::Ace, Suit::Spade),
Card::new(Value::Two, Suit::Spade),
Card::new(Value::Three, Suit::Spade),
]
);
let top = Hand::from(
vec![
Card::new(Value::Jack, Suit::Spade),
Card::new(Value::Queen, Suit::Spade),
Card::new(Value::King, Suit::Spade),
]
);
let stacked = bottom.stack_top(top);
print_hand(&stacked)
}
#[test]
fn stack_bottom() {
let top = Hand::from(
vec![
Card::new(Value::Ace, Suit::Spade),
Card::new(Value::Two, Suit::Spade),
Card::new(Value::Three, Suit::Spade),
]
);
let bottom = Hand::from(
vec![
Card::new(Value::Four, Suit::Spade),
Card::new(Value::Five, Suit::Spade),
Card::new(Value::Six, Suit::Spade),
]
);
let stacked = top.stack_bottom(bottom);
print_hand(&stacked)
}
#[test]
fn insert() {
let mut h = Hand::from(
vec![
Card::new(Value::Ace, Suit::Spade),
Card::new(Value::Three, Suit::Spade),
Card::new(Value::Four, Suit::Spade),
]
);
h = h.insert(1, Card::new(Value::Two, Suit::Spade));
print_hand(&h)
}
#[test]
fn random_cards() {
let now = Instant::now();
for _i in 0..100 {
println!("{}", cards::Card::random().string())
}
println!("{} ms", now.elapsed().as_millis())
}
fn print_hand(hand: &hand::Hand) {
for card in &hand.vec {
println!("{}", card.string())
}
}
}