little more code coverage

This commit is contained in:
2019-02-09 18:10:44 +07:00
parent 69103badbf
commit 13767cdea0
5 changed files with 87 additions and 3 deletions

View File

@@ -7,5 +7,36 @@
#include "_high.hpp"
using namespace e2d;
TEST_CASE("actor") {
namespace
{
class safe_starter_initializer final : private noncopyable {
public:
safe_starter_initializer() {
modules::initialize<starter>(0, nullptr,
starter::parameters(
engine::parameters("world_untests", "enduro2d")
.without_graphics(true)));
}
~safe_starter_initializer() noexcept {
modules::shutdown<starter>();
}
};
}
TEST_CASE("actor") {
safe_starter_initializer initializer;
world& w = the<world>();
SECTION("ctor") {
auto a = actor::create(w.registry().create_entity());
REQUIRE(w.registry().alive_entity(a->entity()));
{
const_actor_iptr ca = a;
REQUIRE(w.registry().alive_entity(ca->entity()));
}
}
SECTION("as_node") {
auto a = actor::create(w.registry().create_entity());
w.scene()->root()->add_child(a);
}
}

View File

@@ -391,6 +391,16 @@ TEST_CASE("node") {
}
SECTION("last_child/first_child") {
auto p = node::create();
REQUIRE_FALSE(p->last_child());
REQUIRE_FALSE(p->first_child());
{
const_node_iptr cp = p;
REQUIRE_FALSE(cp->last_child());
REQUIRE_FALSE(cp->first_child());
}
auto n1 = node::create(p);
auto n2 = node::create(p);
auto n3 = node::create(p);
@@ -817,6 +827,23 @@ TEST_CASE("node") {
REQUIRE(fake_node::s_parent_changes == 6);
REQUIRE(fake_node::s_children_changes == 4);
}
SECTION("transform") {
auto p = node::create();
REQUIRE(p->transform() == t3f::identity());
REQUIRE(p->translation() == v3f::zero());
REQUIRE(p->rotation() == q4f::identity());
REQUIRE(p->scale() == v3f::unit());
p->translation(v3f(1,2,3));
REQUIRE(p->translation() == v3f(1,2,3));
p->rotation(q4f(1,2,3,4));
REQUIRE(p->rotation() == q4f(1,2,3,4));
p->scale(v3f(1,2,3));
REQUIRE(p->scale() == v3f(1,2,3));
}
SECTION("local_matrix") {
{
auto p = node::create();

View File

@@ -8,4 +8,14 @@
using namespace e2d;
TEST_CASE("scene") {
SECTION("ctor") {
auto s = scene::create();
REQUIRE(s);
REQUIRE(s->root());
{
const_scene_iptr cs = s;
REQUIRE(cs->root());
}
}
}

View File

@@ -24,8 +24,20 @@ namespace
};
}
TEST_CASE("world"){
TEST_CASE("world") {
safe_starter_initializer initializer;
world& w = the<world>();
REQUIRE(w.scene());
const world& cw = w;
SECTION("scene") {
REQUIRE(w.scene());
REQUIRE(cw.scene());
}
SECTION("registry") {
auto e = w.registry().create_entity();
REQUIRE(cw.registry().alive_entity(e));
REQUIRE(w.registry().destroy_entity(e));
REQUIRE_FALSE(cw.registry().alive_entity(e));
}
}

View File

@@ -8,6 +8,10 @@
using namespace e2d;
TEST_CASE("rect") {
{
REQUIRE(b2i::zero() == b2i(0,0,0,0));
REQUIRE(b2i::unit() == b2i(0,0,1,1));
}
{
REQUIRE(b2i().position == v2i(0,0));
REQUIRE(b2i().size == v2i(0,0));