feat: add Die and Dice structs with grab and and_grab methods
This commit is contained in:
23
01.workspace/oxydice_lib/src/tst/dice_grab.rs
Normal file
23
01.workspace/oxydice_lib/src/tst/dice_grab.rs
Normal file
@@ -0,0 +1,23 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::*;
|
||||
#[test]
|
||||
fn dice_grab_should_create_a_new_handful_of_dice() {
|
||||
let dice_handful = Dice::grab(3, 6);
|
||||
assert_eq!(dice_handful.handful.len(), 3);
|
||||
for die in dice_handful.handful {
|
||||
assert_eq!(die.sides, 6);
|
||||
}
|
||||
}
|
||||
#[test]
|
||||
fn test_dice_and_grab_should_add_more_dice_to_handful() {
|
||||
let initial_dice = Dice::grab(2, 6);
|
||||
let initial_count = initial_dice.handful.len();
|
||||
let new_dice_handful = initial_dice.and_grab(2, 8);
|
||||
assert_eq!(new_dice_handful.handful.len(), initial_count + 2);
|
||||
// Check the sides of the newly added dice
|
||||
for i in initial_count..new_dice_handful.handful.len() {
|
||||
assert_eq!(new_dice_handful.handful[i].sides, 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
pub mod dice_grab;
|
||||
|
||||
Reference in New Issue
Block a user