use noctisroll::prelude::*;
#[test]
fn test_standard_dice() {
let dice = StandardDice::new(2, 6);
let result = dice.roll();
assert!(result.total >= 2 && result.total <= 12);
assert_eq!(result.rolls.len(), 2);
let dice = StandardDice::new(4, 6).keep_highest(2);
let result = dice.roll();
assert!(result.total >= 2 && result.total <= 12);
assert_eq!(result.rolls.len(), 2);
let dice = StandardDice::new(4, 6).keep_lowest(2);
let result = dice.roll();
assert!(result.total >= 2 && result.total <= 12);
assert_eq!(result.rolls.len(), 2);
}
#[test]
fn test_fate_dice() {
let dice = FateDice::new(4);
let result = dice.roll();
assert!(result.total >= -4 && result.total <= 4);
assert_eq!(result.rolls.len(), 4);
}
#[test]
fn test_exploding_dice() {
let dice = ExplodingDice::new(2, 6, 6); let result = dice.roll();
assert!(result.rolls.len() >= 2);
for roll in &result.rolls {
assert!(roll.value >= 1 && roll.value <= 6);
}
}
#[test]
fn test_dice_validation() {
let dice = StandardDice::new(2, 0).keep_lowest(12);
assert!(dice.validate().is_err());
let dice = StandardDice::new(2, 6);
assert!(dice.validate().is_ok());
let dice = StandardDice::new(0, 6);
assert!(dice.validate().is_ok());
}
#[test]
fn test_roll_statistics() {
use noctisroll::utils::RollStatistics;
let dice = StandardDice::new(100, 6);
let result = dice.roll();
let stats = RollStatistics::from_result(&result);
assert!(stats.min >= 1 && stats.min <= 6);
assert!(stats.max >= 1 && stats.max <= 6);
assert!(stats.mean >= 1.0 && stats.mean <= 6.0);
}
#[test]
fn test_convenience_functions() {
let dice = d(2, 20);
let result = dice.roll();
assert!(result.total >= 2 && result.total <= 40);
let dice = f(4);
let result = dice.roll();
assert!(result.total >= -4 && result.total <= 4);
let dice = x(2, 6, 6);
let result = dice.roll();
assert!(result.rolls.len() >= 2);
}
#[test]
fn test_dice_pool() {
let pool = InfiniteAddingPool::new(5, 8); let result = pool.roll();
assert!(result.total >= 0);
let pool = DoubleCrossPool::new(5, 8); let result = pool.roll();
assert!(result.total >= 1); }
#[test]
fn test_parse_dice_notation() {
use noctisroll::utils::parse_dice_notation;
let dice = parse_dice_notation("d20").unwrap();
let result = dice.roll();
assert!(result.total >= 1 && result.total <= 20);
let dice = parse_dice_notation("2d6").unwrap();
let result = dice.roll();
assert!(result.total >= 2 && result.total <= 12);
let dice = parse_dice_notation("4dF").unwrap(); let result = dice.roll();
assert!(result.total >= -4 && result.total <= 4);
assert!(parse_dice_notation("invalid").is_err());
}