File tree 1 file changed +33
-0
lines changed
crates/bevy_ecs/src/world
1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -684,3 +684,36 @@ fn with_filter_raw(storage_type: StorageType) {
684
684
. try_into ( )
685
685
. unwrap ( ) ;
686
686
}
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
+ }
You can’t perform that action at this time.
0 commit comments