tests
This commit is contained in:
5
Makefile
5
Makefile
@@ -1,7 +1,7 @@
|
|||||||
BLENDER = ../../blender-3.3.1-linux-x64/blender
|
BLENDER = ../../blender-3.3.1-linux-x64/blender
|
||||||
SERVER = src/godot/bin/godot_server.x11.opt.tools.64
|
SERVER = src/godot/bin/godot_server.x11.opt.tools.64
|
||||||
|
|
||||||
.PHONY: all godot-editor-main export export-models export-clothes export-clean export-linux-demo export-windows-demo export-binaries patch
|
.PHONY: all godot-editor-main export export-models export-clothes export-clean export-linux-demo export-windows-demo export-binaries patch tests
|
||||||
all: godot-editor-main godot-main
|
all: godot-editor-main godot-main
|
||||||
ARCH=$(patsubst aarch64,arm64,$(shell uname -i))
|
ARCH=$(patsubst aarch64,arm64,$(shell uname -i))
|
||||||
godot-main: patch
|
godot-main: patch
|
||||||
@@ -37,4 +37,7 @@ export-binaries:
|
|||||||
$(SERVER) --path godot --export windows_demo ../export/office-demo-windows.x86_64.exe
|
$(SERVER) --path godot --export windows_demo ../export/office-demo-windows.x86_64.exe
|
||||||
$(SERVER) --path godot --export-debug windows_demo ../export/office-demo-debug-windows.x86_64.exe
|
$(SERVER) --path godot --export-debug windows_demo ../export/office-demo-debug-windows.x86_64.exe
|
||||||
|
|
||||||
|
tests:
|
||||||
|
make -C tests all
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
17
tests/Makefile
Normal file
17
tests/Makefile
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
all: graph_test entity_test rect2i
|
||||||
|
|
||||||
|
CFLAGS = -I../src/flecs/distr
|
||||||
|
CXXFLAGS = -I../src/flecs/distr -I../src/modules/stream/ui -I../src/godot -I../src/godot/platform/x11
|
||||||
|
|
||||||
|
graph_test: graph_module.o flecs.o
|
||||||
|
$(CXX) -o $@ graph_module.o flecs.o
|
||||||
|
|
||||||
|
entity_test: entity_test.o flecs.o
|
||||||
|
$(CXX) -o $@ entity_test.o flecs.o
|
||||||
|
|
||||||
|
flecs.o: ../src/flecs/distr/flecs.c
|
||||||
|
$(CC) -o $@ -c $<
|
||||||
|
rect2i: rect2i.o
|
||||||
|
$(CXX) -o $@ rect2i.o
|
||||||
|
|
||||||
|
.PHONY: all
|
||||||
BIN
tests/entity_test
Executable file
BIN
tests/entity_test
Executable file
Binary file not shown.
4
tests/entity_test.cpp
Normal file
4
tests/entity_test.cpp
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
int main()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
74
tests/graph_module.cpp
Normal file
74
tests/graph_module.cpp
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
#include <cassert>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <core/math/vector2.h>
|
||||||
|
#include <core/math/rect2.h>
|
||||||
|
#include "flecs.h"
|
||||||
|
#include "graph_module.h"
|
||||||
|
namespace WorldEditor
|
||||||
|
{
|
||||||
|
namespace components
|
||||||
|
{
|
||||||
|
struct buildings_layout_zone
|
||||||
|
{
|
||||||
|
int type;
|
||||||
|
bool align_wall;
|
||||||
|
};
|
||||||
|
struct buildings_layout_area
|
||||||
|
{
|
||||||
|
float area;
|
||||||
|
};
|
||||||
|
struct buildings_layout_system
|
||||||
|
{
|
||||||
|
flecs::entity e;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
struct graph_module
|
||||||
|
{
|
||||||
|
graph_module(flecs::world &ecs)
|
||||||
|
{
|
||||||
|
// ecs.module<graph_module>();
|
||||||
|
flecs::entity s = ecs.system<WorldEditor::components::buildings_layout_zone>("ZoneArea2")
|
||||||
|
.kind(0)
|
||||||
|
.without<WorldEditor::components::buildings_layout_area>()
|
||||||
|
.write<WorldEditor::components::buildings_layout_area>()
|
||||||
|
.each([](flecs::iter &it, size_t count,
|
||||||
|
WorldEditor::components::buildings_layout_zone &f)
|
||||||
|
{
|
||||||
|
flecs::entity zone_e = it.entity(count);
|
||||||
|
printf("running...2\n");
|
||||||
|
zone_e.set<
|
||||||
|
WorldEditor::components::buildings_layout_area>(
|
||||||
|
{ 0.0f }); });
|
||||||
|
ecs.system<WorldEditor::components::buildings_layout_zone>("Zone2")
|
||||||
|
.kind(flecs::OnUpdate)
|
||||||
|
.each([](flecs::iter &it, size_t count,
|
||||||
|
WorldEditor::components::buildings_layout_zone &f)
|
||||||
|
{
|
||||||
|
flecs::entity zone_e = it.entity(count);
|
||||||
|
flecs::world w = zone_e.world();
|
||||||
|
flecs::entity se = w.lookup("::graph_module::ZoneArea2");
|
||||||
|
assert(se.is_valid());
|
||||||
|
w.system(se).run(); });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
flecs::world ecs;
|
||||||
|
ecs.import <graph_module>();
|
||||||
|
printf("1\n");
|
||||||
|
flecs::entity e0 = ecs.entity("base");
|
||||||
|
flecs::entity e1 = ecs.entity("zone1").child_of(e0);
|
||||||
|
printf("2\n");
|
||||||
|
e1.set<WorldEditor::components::buildings_layout_zone>({0, false});
|
||||||
|
flecs::entity e2 = ecs.entity("zone2").child_of(e0);
|
||||||
|
printf("3\n");
|
||||||
|
e2.set<WorldEditor::components::buildings_layout_zone>({1, true});
|
||||||
|
printf("4\n");
|
||||||
|
while (1)
|
||||||
|
ecs.progress();
|
||||||
|
printf("5\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
BIN
tests/graph_test
Executable file
BIN
tests/graph_test
Executable file
Binary file not shown.
20720
tests/qqq.txt
Normal file
20720
tests/qqq.txt
Normal file
File diff suppressed because it is too large
Load Diff
BIN
tests/rect2i
Executable file
BIN
tests/rect2i
Executable file
Binary file not shown.
16
tests/rect2i.cpp
Normal file
16
tests/rect2i.cpp
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#include <cassert>
|
||||||
|
#include <core/math/rect2.h>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
Rect2i clip(0, 0, 2, 2);
|
||||||
|
assert(clip.has_point(Vector2i(0, 0)));
|
||||||
|
assert(clip.has_point(Vector2i(1, 0)));
|
||||||
|
assert(clip.has_point(Vector2i(0, 1)));
|
||||||
|
assert(clip.has_point(Vector2i(1, 1)));
|
||||||
|
assert(clip.encloses(Rect2i(0, 0, 1, 1)));
|
||||||
|
assert(clip.encloses(Rect2i(1, 0, 1, 1)));
|
||||||
|
assert(clip.encloses(Rect2i(0, 1, 1, 1)));
|
||||||
|
assert(clip.encloses(Rect2i(1, 1, 1, 1)));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user