Implemented a deck shuffling algorithm. It will iterate over the deck of cards 1000 times and swap the card it is on with another random card to mix up the deck.
20 lines
471 B
Rust
20 lines
471 B
Rust
use blackjack::Deck;
|
|
|
|
#[test]
|
|
fn check_num_decks() {
|
|
let mut num_card: [u64; 52] = [0; 52];
|
|
let num_decks = 8;
|
|
let mut deck = Deck::new(num_decks as u64);
|
|
deck.shuffle();
|
|
|
|
for _ in 0..deck.deck_size() {
|
|
let next_card = deck.get_next_card();
|
|
let card_pos = next_card.suit * 13 + next_card.value;
|
|
num_card[card_pos as usize] += 1;
|
|
}
|
|
|
|
for card in 0..num_card.len() {
|
|
assert_eq!(num_card[card], num_decks);
|
|
}
|
|
}
|