|
|
|
// Reimplementations of the following tests from Flecs:
|
|
|
|
// https://github.com/SanderMertens/flecs/blob/master/test/api/src/Entity.c
|
|
|
|
|
|
|
|
const std = @import("std");
|
|
|
|
const alloc = std.testing.allocator;
|
|
|
|
const expect = std.testing.expect;
|
|
|
|
const expectFmt = std.testing.expectFmt;
|
|
|
|
const expectEqual = std.testing.expectEqual;
|
|
|
|
const expectEqualStrings = 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(alloc);
|
|
|
|
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(alloc);
|
|
|
|
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 expectEqualStrings("foo", e.getName().?);
|
|
|
|
|
|
|
|
const path2 = try e.getPath(alloc);
|
|
|
|
defer path2.deinit();
|
|
|
|
try expectFmt("foo", "{}", .{path2});
|
|
|
|
}
|