Skip to content

Commit 6bf0160

Browse files
OptimisticPeachBoxyUwU
authored andcommitted
Add an extra test to deal with sparse sets.
1 parent 73b65ff commit 6bf0160

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

crates/bevy_ecs/src/world/tests.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,3 +684,36 @@ fn with_filter_raw(storage_type: StorageType) {
684684
.try_into()
685685
.unwrap();
686686
}
687+
688+
#[test]
689+
pub fn sparse_set_relation_registration() {
690+
let mut world = World::new();
691+
world
692+
.register_relation(ComponentDescriptor::new::<String>(StorageType::SparseSet))
693+
.unwrap();
694+
let mut q = world.query::<&Relation<String>>();
695+
assert!(q.iter(&world).next().is_none());
696+
697+
let target = world.spawn().id();
698+
world
699+
.spawn()
700+
.insert_relation(String::from("UwowU"), target)
701+
.id();
702+
703+
use std::any::TypeId;
704+
let ty_id = world
705+
.components
706+
.get_relationship_kind(TypeId::of::<String>())
707+
.unwrap()
708+
.id();
709+
710+
assert_eq!(
711+
world
712+
.storages
713+
.sparse_sets
714+
.get(ty_id, Some(target))
715+
.unwrap()
716+
.len(),
717+
1
718+
);
719+
}

0 commit comments

Comments
 (0)