@ -2,7 +2,6 @@
/ / https : / / github . com / SanderMertens / flecs / blob / master / test / api / src / Entity . c
/ / https : / / github . com / SanderMertens / flecs / blob / master / test / api / src / Entity . c
const std = @import ( " std " ) ;
const std = @import ( " std " ) ;
const alloc = std . testing . allocator ;
const expect = std . testing . expect ;
const expect = std . testing . expect ;
const expectFmt = std . testing . expectFmt ;
const expectFmt = std . testing . expectFmt ;
const expectEqual = std . testing . expectEqual ;
const expectEqual = std . testing . expectEqual ;
@ -19,7 +18,8 @@ const Path = context.Path;
const World = context . World ;
const World = context . World ;
test " Entity_init_id " {
test " Entity_init_id " {
var world = try World . initMinimal ( alloc ) ;
flecs . init ( std . testing . allocator ) ;
var world = try World . initMinimal ( ) ;
defer world . deinit ( ) ;
defer world . deinit ( ) ;
const e = try world . entity ( . { } , . { } ) ;
const e = try world . entity ( . { } , . { } ) ;
@ -28,29 +28,31 @@ test "Entity_init_id" {
}
}
test " Entity_init_id_name " {
test " Entity_init_id_name " {
var world = try World . initMinimal ( alloc ) ;
flecs . init ( std . testing . allocator ) ;
var world = try World . initMinimal ( ) ;
defer world . deinit ( ) ;
defer world . deinit ( ) ;
const e = try world . entity ( . { . name = " foo " } , . { } ) ;
const e = try world . entity ( . { . name = " foo " } , . { } ) ;
/ / try expect ( e . raw ! = 0 ) ; - - Not necessary , world . entity ( ) returns error if result would be 0 .
/ / try expect ( e . raw ! = 0 ) ; - - Not necessary , world . entity ( ) returns error if result would be 0 .
try expectEqualStrings ( " foo " , e . getName ( ) . ? ) ;
try expectEqualStrings ( " foo " , e . getName ( ) . ? ) ;
const path2 = try e . getPath ( alloc ) ;
const path2 = try e . getPath ( flecs . allocator ) ;
defer path2 . deinit ( ) ;
defer path2 . deinit ( ) ;
try expectFmt ( " foo " , " {} " , . { path2 } ) ;
try expectFmt ( " foo " , " {} " , . { path2 } ) ;
}
}
test " Entity_init_id_path " {
test " Entity_init_id_path " {
var world = try World . initMinimal ( alloc ) ;
flecs . init ( std . testing . allocator ) ;
var world = try World . initMinimal ( ) ;
defer world . deinit ( ) ;
defer world . deinit ( ) ;
const p = try Path . fromString ( " parent.child " , null , alloc ) ;
const p = try Path . fromString ( " parent.child " , null , flecs . allocator ) ;
defer p . deinit ( ) ;
defer p . deinit ( ) ;
const e = try world . entity ( . { . path = p } , . { } ) ;
const e = try world . entity ( . { . path = p } , . { } ) ;
/ / try expect ( e . raw ! = 0 ) ; - - Not necessary , world . entity ( ) returns error if result would be 0 .
/ / try expect ( e . raw ! = 0 ) ; - - Not necessary , world . entity ( ) returns error if result would be 0 .
try expectEqualStrings ( " child " , e . getName ( ) . ? ) ;
try expectEqualStrings ( " child " , e . getName ( ) . ? ) ;
const path = try e . getPath ( alloc ) ;
const path = try e . getPath ( flecs . allocator ) ;
defer path . deinit ( ) ;
defer path . deinit ( ) ;
try expectFmt ( " parent.child " , " {} " , . { path } ) ;
try expectFmt ( " parent.child " , " {} " , . { path } ) ;
}
}