Skip to content

Commit

Permalink
Test setting existing component with entry.
Browse files Browse the repository at this point in the history
  • Loading branch information
Anders429 committed Aug 19, 2022
1 parent 5680e23 commit b77db73
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/world/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1708,6 +1708,26 @@ mod tests {
assert_eq!(result, vec![1, 2, 3]);
}

#[test]
fn entry_set_existing_component() {
let mut world = World::<Registry>::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::<views!(&A), filter::None>()
.map(|result!(a)| a.0)
.collect::<Vec<_>>();
result.sort();
assert_eq!(result, vec![2, 3]);
}

#[test]
fn entry_remove_component() {
let mut world = World::<Registry>::new();
Expand Down

0 comments on commit b77db73

Please sign in to comment.