adds docs, tests unpack_gold_value
This commit is contained in:
@@ -95,19 +95,21 @@ mod tests {
|
||||
use crate::tests;
|
||||
|
||||
#[test]
|
||||
fn new_player_only_with_name() {
|
||||
let n = NewPlayer::new("Féfi", None);
|
||||
assert_eq!(n.name, "Féfi");
|
||||
assert_eq!(n.cp, 0);
|
||||
assert_eq!(n.sp, 0);
|
||||
assert_eq!(n.gp, 0);
|
||||
assert_eq!(n.pp, 0);
|
||||
fn test_unpack_gold_values() {
|
||||
use super::unpack_gold_value;
|
||||
let test_values = [
|
||||
(1.0, (0,0,1,0)),
|
||||
(1.23, (3,2,1,0)),
|
||||
(1.03, (3,0,1,0)),
|
||||
(100.23, (3,2,0,1)),
|
||||
(-100.23, (-3,-2,-0,-1)),
|
||||
(10189.23, (3,2,89,101)),
|
||||
(-8090.20, (0,-2,-90,-80))
|
||||
];
|
||||
|
||||
for (tested, expected) in test_values.into_iter() {
|
||||
assert_eq!(unpack_gold_value(*tested), *expected);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn new_player_with_wealth() {
|
||||
let initial_wealth = (1, 2, 3, 4);
|
||||
let n = NewPlayer::new("Féfi", Some(initial_wealth));
|
||||
assert_eq!(initial_wealth, (n.cp, n.sp, n.gp, n.pp));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user