From e2c3d47f60cf74fe29ced1a32ddd38de9e614eb7 Mon Sep 17 00:00:00 2001 From: Thomas Schaller Date: Mon, 27 May 2019 18:37:33 +0200 Subject: [PATCH] Add tests --- src/world/mod.rs | 54 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/src/world/mod.rs b/src/world/mod.rs index 040aba5b0..1477ec856 100644 --- a/src/world/mod.rs +++ b/src/world/mod.rs @@ -615,6 +615,60 @@ mod tests { ); } + #[test] + fn system_data() { + let mut world = World::empty(); + + world.insert(5u32); + let x = *world.system_data::>(); + assert_eq!(x, 5); + } + + #[test] + fn setup() { + let mut world = World::empty(); + + world.insert(5u32); + world.setup::>(); + let x = *world.system_data::>(); + assert_eq!(x, 5); + + world.remove::(); + world.setup::>(); + let x = *world.system_data::>(); + assert_eq!(x, 0); + } + + #[test] + fn exec() { + let mut world = World::empty(); + + world.exec(|(float, boolean): (Read, Read)| { + assert_eq!(*float, 0.0); + assert_eq!(*boolean, false); + }); + + world.exec(|(mut float, mut boolean): (Write, Write)| { + *float = 4.3; + *boolean = true; + }); + + world.exec(|(float, boolean): (Read, ReadExpect)| { + assert_eq!(*float, 4.3); + assert_eq!(*boolean, true); + }); + } + + #[test] + #[should_panic] + fn exec_panic() { + let mut world = World::empty(); + + world.exec(|(_float, _boolean): (Write, Write)| { + panic!(); + }); + } + #[test] #[should_panic] fn invalid_fetch_by_id0() {