@@ -2924,3 +2924,173 @@ void Query_create_query_while_pending() {
2924
2924
2925
2925
ecs_fini (world );
2926
2926
}
2927
+
2928
+ void Query_not_pair_relation_wildcard () {
2929
+ ecs_world_t * world = ecs_init ();
2930
+
2931
+ ECS_TAG (world , Foo );
2932
+ ECS_TAG (world , RelA );
2933
+ ECS_TAG (world , RelB );
2934
+ ECS_TAG (world , ObjA );
2935
+ ECS_TAG (world , ObjB );
2936
+
2937
+ ecs_query_t * q = ecs_query_new (world , "Foo, !(*, ObjA)" );
2938
+ test_assert (q != NULL );
2939
+
2940
+ ecs_entity_t e1 = ecs_new (world , Foo );
2941
+ ecs_entity_t e2 = ecs_new (world , Foo );
2942
+ ecs_entity_t e3 = ecs_new (world , Foo );
2943
+ ecs_entity_t e4 = ecs_new (world , Foo );
2944
+
2945
+ ecs_add_pair (world , e1 , RelA , ObjA );
2946
+ ecs_add_pair (world , e2 , RelA , ObjB );
2947
+ ecs_add_pair (world , e3 , RelB , ObjA );
2948
+ ecs_add_pair (world , e4 , RelB , ObjB );
2949
+
2950
+ ecs_iter_t it = ecs_query_iter (world , q );
2951
+ test_bool (true, ecs_query_next (& it ));
2952
+ test_int (it .count , 1 );
2953
+ test_uint (it .entities [0 ], e2 );
2954
+ test_uint (ecs_term_id (& it , 2 ), ecs_pair (EcsWildcard , ObjA ));
2955
+
2956
+ test_bool (true, ecs_query_next (& it ));
2957
+ test_int (it .count , 1 );
2958
+ test_uint (it .entities [0 ], e4 );
2959
+ test_uint (ecs_term_id (& it , 2 ), ecs_pair (EcsWildcard , ObjA ));
2960
+
2961
+ test_bool (false, ecs_query_next (& it ));
2962
+
2963
+ ecs_fini (world );
2964
+ }
2965
+
2966
+ void Query_not_pair_object_wildcard () {
2967
+ ecs_world_t * world = ecs_init ();
2968
+
2969
+ ECS_TAG (world , Foo );
2970
+ ECS_TAG (world , RelA );
2971
+ ECS_TAG (world , RelB );
2972
+ ECS_TAG (world , ObjA );
2973
+ ECS_TAG (world , ObjB );
2974
+
2975
+ ecs_query_t * q = ecs_query_new (world , "Foo, !(RelA, *)" );
2976
+ test_assert (q != NULL );
2977
+
2978
+ ecs_entity_t e1 = ecs_new (world , Foo );
2979
+ ecs_entity_t e2 = ecs_new (world , Foo );
2980
+ ecs_entity_t e3 = ecs_new (world , Foo );
2981
+ ecs_entity_t e4 = ecs_new (world , Foo );
2982
+
2983
+ ecs_add_pair (world , e1 , RelA , ObjA );
2984
+ ecs_add_pair (world , e2 , RelA , ObjB );
2985
+ ecs_add_pair (world , e3 , RelB , ObjA );
2986
+ ecs_add_pair (world , e4 , RelB , ObjB );
2987
+
2988
+ ecs_iter_t it = ecs_query_iter (world , q );
2989
+ test_bool (true, ecs_query_next (& it ));
2990
+ test_int (it .count , 1 );
2991
+ test_uint (it .entities [0 ], e3 );
2992
+ test_uint (ecs_term_id (& it , 2 ), ecs_pair (RelA , EcsWildcard ));
2993
+
2994
+ test_bool (true, ecs_query_next (& it ));
2995
+ test_int (it .count , 1 );
2996
+ test_uint (it .entities [0 ], e4 );
2997
+ test_uint (ecs_term_id (& it , 2 ), ecs_pair (RelA , EcsWildcard ));
2998
+
2999
+ test_bool (false, ecs_query_next (& it ));
3000
+
3001
+ ecs_fini (world );
3002
+ }
3003
+
3004
+ void Query_two_pair_wildcards_one_not () {
3005
+ ecs_world_t * world = ecs_init ();
3006
+
3007
+ ECS_TAG (world , Foo );
3008
+ ECS_TAG (world , RelA );
3009
+ ECS_TAG (world , RelB );
3010
+ ECS_TAG (world , ObjA );
3011
+ ECS_TAG (world , ObjB );
3012
+
3013
+ ecs_query_t * q = ecs_query_new (world , "Foo, (RelA, *), !(RelB, *)" );
3014
+ test_assert (q != NULL );
3015
+
3016
+ ecs_entity_t e1 = ecs_new (world , Foo );
3017
+ ecs_entity_t e2 = ecs_new (world , Foo );
3018
+ ecs_entity_t e3 = ecs_new (world , Foo );
3019
+ ecs_entity_t e4 = ecs_new (world , Foo );
3020
+
3021
+ ecs_add_pair (world , e1 , RelA , ObjA );
3022
+ ecs_add_pair (world , e1 , RelB , ObjA );
3023
+
3024
+ ecs_add_pair (world , e2 , RelA , ObjA );
3025
+
3026
+ ecs_add_pair (world , e3 , RelA , ObjB );
3027
+ ecs_add_pair (world , e3 , RelB , ObjB );
3028
+
3029
+ ecs_add_pair (world , e4 , RelA , ObjB );
3030
+
3031
+ ecs_iter_t it = ecs_query_iter (world , q );
3032
+ test_bool (true, ecs_query_next (& it ));
3033
+ test_int (it .count , 1 );
3034
+ test_uint (it .entities [0 ], e2 );
3035
+ test_uint (ecs_term_id (& it , 1 ), Foo );
3036
+ test_uint (ecs_term_id (& it , 2 ), ecs_pair (RelA , ObjA ));
3037
+ test_uint (ecs_term_id (& it , 3 ), ecs_pair (RelB , EcsWildcard ));
3038
+
3039
+ test_bool (true, ecs_query_next (& it ));
3040
+ test_int (it .count , 1 );
3041
+ test_uint (it .entities [0 ], e4 );
3042
+ test_uint (ecs_term_id (& it , 1 ), Foo );
3043
+ test_uint (ecs_term_id (& it , 2 ), ecs_pair (RelA , ObjB ));
3044
+ test_uint (ecs_term_id (& it , 3 ), ecs_pair (RelB , EcsWildcard ));
3045
+
3046
+ test_bool (false, ecs_query_next (& it ));
3047
+
3048
+ ecs_fini (world );
3049
+ }
3050
+
3051
+ void Query_two_pair_wildcards_one_not_any () {
3052
+ ecs_world_t * world = ecs_init ();
3053
+
3054
+ ECS_TAG (world , Foo );
3055
+ ECS_TAG (world , RelA );
3056
+ ECS_TAG (world , RelB );
3057
+ ECS_TAG (world , ObjA );
3058
+ ECS_TAG (world , ObjB );
3059
+
3060
+ ecs_query_t * q = ecs_query_new (world , "Foo, (RelA, *), !(RelB, _)" );
3061
+ test_assert (q != NULL );
3062
+
3063
+ ecs_entity_t e1 = ecs_new (world , Foo );
3064
+ ecs_entity_t e2 = ecs_new (world , Foo );
3065
+ ecs_entity_t e3 = ecs_new (world , Foo );
3066
+ ecs_entity_t e4 = ecs_new (world , Foo );
3067
+
3068
+ ecs_add_pair (world , e1 , RelA , ObjA );
3069
+ ecs_add_pair (world , e1 , RelB , ObjA );
3070
+
3071
+ ecs_add_pair (world , e2 , RelA , ObjA );
3072
+
3073
+ ecs_add_pair (world , e3 , RelA , ObjB );
3074
+ ecs_add_pair (world , e3 , RelB , ObjB );
3075
+
3076
+ ecs_add_pair (world , e4 , RelA , ObjB );
3077
+
3078
+ ecs_iter_t it = ecs_query_iter (world , q );
3079
+ test_bool (true, ecs_query_next (& it ));
3080
+ test_int (it .count , 1 );
3081
+ test_uint (it .entities [0 ], e2 );
3082
+ test_uint (ecs_term_id (& it , 1 ), Foo );
3083
+ test_uint (ecs_term_id (& it , 2 ), ecs_pair (RelA , ObjA ));
3084
+ test_uint (ecs_term_id (& it , 3 ), ecs_pair (RelB , EcsWildcard ));
3085
+
3086
+ test_bool (true, ecs_query_next (& it ));
3087
+ test_int (it .count , 1 );
3088
+ test_uint (it .entities [0 ], e4 );
3089
+ test_uint (ecs_term_id (& it , 1 ), Foo );
3090
+ test_uint (ecs_term_id (& it , 2 ), ecs_pair (RelA , ObjB ));
3091
+ test_uint (ecs_term_id (& it , 3 ), ecs_pair (RelB , EcsWildcard ));
3092
+
3093
+ test_bool (false, ecs_query_next (& it ));
3094
+
3095
+ ecs_fini (world );
3096
+ }
0 commit comments