@@ -381,6 +381,177 @@ void Hierarchies_path_w_entity_id(void) {
381381 ecs_fini (world );
382382}
383383
384+ void Hierarchies_path_escaped_sep (void ) {
385+ ecs_world_t * world = ecs_mini ();
386+
387+ ecs_entity_t e = ecs_entity (world , { .name = "foo\\.bar" });
388+ test_assert (e != 0 );
389+ test_str (ecs_get_name (world , e ), "foo.bar" );
390+ test_assert (ecs_get_parent (world , e ) == 0 );
391+ test_assert (ecs_lookup (world , "foo\\.bar" ) == e );
392+
393+ char * path = ecs_get_path (world , e );
394+ test_str (path , "foo\\.bar" );
395+ ecs_os_free (path );
396+
397+ ecs_fini (world );
398+ }
399+
400+ void Hierarchies_path_escaped_two_sep (void ) {
401+ ecs_world_t * world = ecs_mini ();
402+
403+ ecs_entity_t e = ecs_entity (world , { .name = "foo\\.bar\\.woo" });
404+ test_assert (e != 0 );
405+ test_str (ecs_get_name (world , e ), "foo.bar.woo" );
406+ test_assert (ecs_get_parent (world , e ) == 0 );
407+ test_assert (ecs_lookup (world , "foo\\.bar\\.woo" ) == e );
408+
409+ char * path = ecs_get_path (world , e );
410+ test_str (path , "foo\\.bar\\.woo" );
411+ ecs_os_free (path );
412+
413+ ecs_fini (world );
414+ }
415+
416+ void Hierarchies_path_escaped_two_consecutive_sep (void ) {
417+ ecs_world_t * world = ecs_mini ();
418+
419+ ecs_entity_t e = ecs_entity (world , { .name = "foo\\.\\.bar\\.woo" });
420+ test_assert (e != 0 );
421+ test_str (ecs_get_name (world , e ), "foo..bar.woo" );
422+ test_assert (ecs_get_parent (world , e ) == 0 );
423+ test_assert (ecs_lookup (world , "foo\\.\\.bar\\.woo" ) == e );
424+
425+ char * path = ecs_get_path (world , e );
426+ test_str (path , "foo\\.\\.bar\\.woo" );
427+ ecs_os_free (path );
428+
429+ ecs_fini (world );
430+ }
431+
432+ void Hierarchies_path_escaped_sep_at_begin (void ) {
433+ ecs_world_t * world = ecs_mini ();
434+
435+ ecs_entity_t e = ecs_entity (world , { .name = "\\.foo\\.bar" });
436+ test_assert (e != 0 );
437+ test_str (ecs_get_name (world , e ), ".foo.bar" );
438+ test_assert (ecs_get_parent (world , e ) == 0 );
439+ test_assert (ecs_lookup (world , "\\.foo\\.bar" ) == e );
440+
441+ char * path = ecs_get_path (world , e );
442+ test_str (path , "\\.foo\\.bar" );
443+ ecs_os_free (path );
444+
445+ ecs_fini (world );
446+ }
447+
448+ void Hierarchies_path_escaped_sep_at_end (void ) {
449+ ecs_world_t * world = ecs_mini ();
450+
451+ ecs_entity_t e = ecs_entity (world , { .name = "foo\\.bar\\." });
452+ test_assert (e != 0 );
453+ test_str (ecs_get_name (world , e ), "foo.bar." );
454+ test_assert (ecs_get_parent (world , e ) == 0 );
455+ test_assert (ecs_lookup (world , "foo\\.bar\\." ) == e );
456+
457+ char * path = ecs_get_path (world , e );
458+ test_str (path , "foo\\.bar\\." );
459+ ecs_os_free (path );
460+
461+ ecs_fini (world );
462+ }
463+
464+ void Hierarchies_path_escaped_sep_w_parent (void ) {
465+ ecs_world_t * world = ecs_mini ();
466+
467+ ecs_entity_t e = ecs_entity (world , { .name = "parent.foo\\.bar" });
468+ test_assert (e != 0 );
469+ ecs_entity_t p = ecs_lookup (world , "parent" );
470+ test_assert (p != 0 );
471+
472+ test_str (ecs_get_name (world , e ), "foo.bar" );
473+ test_assert (ecs_get_parent (world , e ) == p );
474+ test_assert (ecs_lookup (world , "parent.foo\\.bar" ) == e );
475+
476+ char * path = ecs_get_path (world , e );
477+ test_str (path , "parent.foo\\.bar" );
478+ ecs_os_free (path );
479+
480+ ecs_fini (world );
481+ }
482+
483+ void Hierarchies_path_only_escaped_sep (void ) {
484+ ecs_world_t * world = ecs_mini ();
485+
486+ ecs_entity_t e = ecs_entity (world , { .name = "\\." });
487+ test_assert (e != 0 );
488+
489+ test_str (ecs_get_name (world , e ), "." );
490+ test_assert (ecs_get_parent (world , e ) == 0 );
491+ test_assert (ecs_lookup (world , "\\." ) == e );
492+
493+ char * path = ecs_get_path (world , e );
494+ test_str (path , "\\." );
495+ ecs_os_free (path );
496+
497+ ecs_fini (world );
498+ }
499+
500+ void Hierarchies_path_only_escaped_sep_w_parent (void ) {
501+ ecs_world_t * world = ecs_mini ();
502+
503+ ecs_entity_t e = ecs_entity (world , { .name = "parent.\\." });
504+ test_assert (e != 0 );
505+ ecs_entity_t p = ecs_lookup (world , "parent" );
506+ test_assert (p != 0 );
507+
508+ test_str (ecs_get_name (world , e ), "." );
509+ test_assert (ecs_get_parent (world , e ) == p );
510+ test_assert (ecs_lookup (world , "parent.\\." ) == e );
511+
512+ char * path = ecs_get_path (world , e );
513+ test_str (path , "parent.\\." );
514+ ecs_os_free (path );
515+
516+ ecs_fini (world );
517+ }
518+
519+ void Hierarchies_path_only_escaped_two_sep (void ) {
520+ ecs_world_t * world = ecs_mini ();
521+
522+ ecs_entity_t e = ecs_entity (world , { .name = "\\.\\." });
523+ test_assert (e != 0 );
524+
525+ test_str (ecs_get_name (world , e ), ".." );
526+ test_assert (ecs_get_parent (world , e ) == 0 );
527+ test_assert (ecs_lookup (world , "\\.\\." ) == e );
528+
529+ char * path = ecs_get_path (world , e );
530+ test_str (path , "\\.\\." );
531+ ecs_os_free (path );
532+
533+ ecs_fini (world );
534+ }
535+
536+ void Hierarchies_path_only_escaped_two_sep_w_parent (void ) {
537+ ecs_world_t * world = ecs_mini ();
538+
539+ ecs_entity_t e = ecs_entity (world , { .name = "parent.\\.\\." });
540+ test_assert (e != 0 );
541+ ecs_entity_t p = ecs_lookup (world , "parent" );
542+ test_assert (p != 0 );
543+
544+ test_str (ecs_get_name (world , e ), ".." );
545+ test_assert (ecs_get_parent (world , e ) == p );
546+ test_assert (ecs_lookup (world , "parent.\\.\\." ) == e );
547+
548+ char * path = ecs_get_path (world , e );
549+ test_str (path , "parent.\\.\\." );
550+ ecs_os_free (path );
551+
552+ ecs_fini (world );
553+ }
554+
384555void Hierarchies_lookup_depth_0 (void ) {
385556 ecs_world_t * world = ecs_mini ();
386557
0 commit comments