parent
15640c1b56
commit
5ad3647da0
3 changed files with 44 additions and 0 deletions
@ -0,0 +1,40 @@ |
||||
// Reimplementations of the following tests from Flecs: |
||||
// https://github.com/SanderMertens/flecs/blob/master/test/api/src/Entity.c |
||||
|
||||
const std = @import("std"); |
||||
const expect = std.testing.expect; |
||||
const expectEql = std.testing.expectEqual; |
||||
const expectStrEql = std.testing.expectEqualStrings; |
||||
|
||||
const util = @import("./util.zig"); |
||||
|
||||
const flecs = @import("../src/main.zig"); |
||||
const c = flecs.c; |
||||
|
||||
const context = flecs.Context(void); |
||||
const World = context.World; |
||||
const Entity = context.Entity; |
||||
|
||||
test "Entity_init_id" { |
||||
var world = try World.initMinimal(std.testing.allocator); |
||||
defer world.deinit(); |
||||
|
||||
const e = try world.entity(.{}, .{}); |
||||
// try expect(e.raw != 0); -- Not necessary, world.entity() returns error if result would be 0. |
||||
try expect(c.ecs_get_type(world.raw, e.raw) == null); |
||||
} |
||||
|
||||
test "Entity_init_id_name" { |
||||
var world = try World.initMinimal(std.testing.allocator); |
||||
defer world.deinit(); |
||||
|
||||
const e = try world.entity(.{ .name = "foo" }, .{}); |
||||
// try expect(e.raw != 0); -- Not necessary, world.entity() returns error if result would be 0. |
||||
try expectStrEql("foo", e.getName().?); |
||||
|
||||
// TODO: Implement EntityPath. |
||||
const path = c.ecs_get_fullpath(world.raw, e.raw); |
||||
defer c.ecs_os_api.free_.?(path); |
||||
try expect(path != null); |
||||
try expectStrEql("foo", std.mem.sliceTo(path.?, 0)); |
||||
} |
@ -1,4 +1,5 @@ |
||||
test { |
||||
_ = @import("../src/main.zig"); |
||||
_ = @import("./entity.zig"); |
||||
_ = @import("./world.zig"); |
||||
} |
||||
|
Loading…
Reference in new issue