A bunch of work on unit testing
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-11-26 15:33:50 +01:00
parent a6a9cb573f
commit d1ed14119d
10 changed files with 332 additions and 26 deletions

View File

@@ -54,8 +54,6 @@ pub mod tests {
&StringKey::new("test_ability"),
Arc::new(Ability::new(&"test_ability".into(), &"test_ability".into(), Vec::new())),
);
// Drops borrow as mut
lib
}

View File

@@ -66,7 +66,7 @@ pub mod tests {
0.0,
0,
Vec::new(),
StaticStatisticSet::default(),
StaticStatisticSet::new(10, 10, 10, 10, 10, 10),
Vec::new(),
Vec::new(),
LearnableMoves::new(),

View File

@@ -174,4 +174,20 @@ pub mod tests {
assert_approx_eq!(r.get_effectiveness(t0, &[t1, t1]), 0.25);
assert_approx_eq!(r.get_effectiveness(t1, &[t0, t0]), 4.0);
}
#[test]
fn add_two_types_get_type_name() {
let mut lib = TypeLibrary::new(2);
// Borrow as mut so we can insert
let w = &mut lib;
let t0 = w.register_type(&"foo".into());
let t1 = w.register_type(&"bar".into());
// Drops borrow as mut
// Borrow as read so we can read
let r = &lib;
assert_eq!(r.get_type_name(t0).unwrap(), "foo".into());
assert_eq!(r.get_type_name(t1).unwrap(), "bar".into());
}
}