Merge branch 'main' into 'main'

fix tests

See merge request kaist-cp-class/cs220-private!30
This commit is contained in:
Jungin Rhee
2023-09-12 04:28:44 +00:00
3 changed files with 20 additions and 9 deletions

View File

@@ -33,7 +33,7 @@ mod test {
let it = || (1..=5).cycle().my_zip((1..=3).cycle()).map(|(x, y)| x * y);
let take15 = vec![
2, // 1 * 1,
1, // 1 * 1,
4, // 2 * 2,
9, // 3 * 3,
4, // 4 * 1,

View File

@@ -24,8 +24,7 @@ mod test {
}
}
#[test]
fn can_every_husband_rescue_his_wife() {
fn can_every_husband_rescue_his_wife() -> bool {
// HINT: https://en.wikipedia.org/wiki/100_prisoners_problem
const WIVES: usize = 100;
@@ -37,7 +36,7 @@ mod test {
rooms
});
assert!((0..WIVES).all(|his_wife| {
(0..WIVES).all(|his_wife| {
// A new husband steps into the labyrinth to rescue his wife...!
let husband = Box::new(Husband::seeking(his_wife /*👩*/));
let strategy = Box::new(husband.has_devised_a_strategy());
@@ -57,6 +56,18 @@ mod test {
})
.is_some(/* The husband has successfully rescued his wife! 👫*/)
// or is_none(/* The unfortunate husband has encountered the Minotaur and... 🪓*/)
}));
})
}
#[test]
fn main() {
let mut num_success = 0;
for _ in 0..10000 {
if can_every_husband_rescue_his_wife() {
num_success += 1
}
}
assert!(num_success > 3000)
}
}

View File

@@ -9,9 +9,9 @@ mod test_card {
use std::thread;
use std::time::Duration;
const NUM_CARDS: usize = 10_000;
const DURATION: u64 = 1;
const NUM_ENEMIES: usize = 100;
const NUM_CARDS: usize = 10000;
const DURATION: u64 = 20;
const NUM_ENEMIES: usize = 25;
#[derive(Clone, Debug)]
struct Card {
@@ -104,7 +104,7 @@ mod test_card {
let idx = init + (cnt % dist);
match ground.get_card_color(idx) {
Color::White => ground.flip_card(idx, Color::Blue),
Color::Blue => thread::sleep(Duration::from_micros(1)),
Color::Blue => thread::sleep(Duration::from_micros(10)),
};
cnt += 1;
}