test(core): add scoring boundary tests for non-waste destinations
Three new tests: non-waste→tableau scores zero (tableau restack and impossible foundation→tableau), move→stock/waste scores zero (guard against non-obvious destinations panicking), and time_bonus capped at i32::MAX via the .min() guard. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -70,4 +70,27 @@ mod tests {
|
|||||||
fn time_bonus_at_one_second() {
|
fn time_bonus_at_one_second() {
|
||||||
assert_eq!(compute_time_bonus(1), 700_000);
|
assert_eq!(compute_time_bonus(1), 700_000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn non_waste_to_tableau_scores_zero() {
|
||||||
|
// Foundation → Tableau is impossible in practice but must score 0.
|
||||||
|
assert_eq!(score_move(&PileType::Foundation(Suit::Clubs), &PileType::Tableau(0)), 0);
|
||||||
|
// Tableau → Tableau (restack) scores 0.
|
||||||
|
assert_eq!(score_move(&PileType::Tableau(1), &PileType::Tableau(2)), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn move_to_stock_or_waste_scores_zero() {
|
||||||
|
// These destinations are illegal moves in practice, but the function
|
||||||
|
// must not panic and should return 0.
|
||||||
|
assert_eq!(score_move(&PileType::Waste, &PileType::Stock), 0);
|
||||||
|
assert_eq!(score_move(&PileType::Waste, &PileType::Waste), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn time_bonus_is_capped_at_i32_max_for_huge_values() {
|
||||||
|
// Very short elapsed time would overflow without the .min() guard.
|
||||||
|
let bonus = compute_time_bonus(1);
|
||||||
|
assert!(bonus <= i32::MAX, "time bonus must fit in i32");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user