From b77db737b140fa17cca69001549001a3ed54a618 Mon Sep 17 00:00:00 2001 From: Anders429 Date: Fri, 19 Aug 2022 15:54:31 -0700 Subject: [PATCH] Test setting existing component with entry. --- src/world/mod.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/world/mod.rs b/src/world/mod.rs index 32ec55ce..c12f5a93 100644 --- a/src/world/mod.rs +++ b/src/world/mod.rs @@ -1708,6 +1708,26 @@ mod tests { assert_eq!(result, vec![1, 2, 3]); } + #[test] + fn entry_set_existing_component() { + let mut world = World::::new(); + + let entity_identifier = world.insert(entity!(A(1), B('a'))); + world.insert(entity!(A(2))); + world.insert(entity!(B('b'))); + world.insert(entity!()); + + let mut entry = assert_some!(world.entry(entity_identifier)); + entry.add(A(3)); + + let mut result = world + .query::() + .map(|result!(a)| a.0) + .collect::>(); + result.sort(); + assert_eq!(result, vec![2, 3]); + } + #[test] fn entry_remove_component() { let mut world = World::::new();