adding unit test crashing on addEntity

This commit is contained in:
Bluub
2021-05-31 14:54:53 +02:00
parent 79aa4cc86c
commit 47aac95801
4 changed files with 65 additions and 13 deletions
+53
View File
@@ -0,0 +1,53 @@
//
// Created by Louis Auzuret on 5/31/21.
//
#include <catch2/catch.hpp>
#include "Entity/Entity.hpp"
#include "Component/Position/PositionComponent.hpp"
#include "System/Collision/CollisionSystem.hpp"
#include "Wal.hpp"
#define private public
#include "Component/Collision/CollisionComponent.hpp"
using namespace WAL;
using namespace BBM;
TEST_CASE("Collsion test", "[Component][System]")
{
Wal wal;
wal.scene->addEntity("player")
.addComponent<PositionComponent>();
// .addComponent<CollisionComponent>([](Entity &actual, const Entity &) {
// auto &pos = actual.getComponent<PositionComponent>();
// pos.position.x = 1;
// pos.position.y = 1;
// pos.position.z = 1;
// }, 5.0);
//Entity &entity = wal.scene->getEntities()[0];
//
//REQUIRE(entity.getComponent<PositionComponent>().position == Vector3f());
//
//entity.getComponent<CollisionComponent>()._bound.x = 5;
//entity.getComponent<CollisionComponent>()._bound.y = 5;
//entity.getComponent<CollisionComponent>()._bound.z = 5;
//
//CollisionSystem collision(wal);
//collision.onUpdate(entity, std::chrono::nanoseconds(1));
//collision.onFixedUpdate(entity);
//REQUIRE(entity.getComponent<PositionComponent>().position.x == 0);
//REQUIRE(entity.getComponent<PositionComponent>().position.y == 0);
//REQUIRE(entity.getComponent<PositionComponent>().position.z == 0);
//
//
//wal.scene->addEntity("block")
// .addComponent<PositionComponent>()
// .addComponent<CollisionComponent>([](Entity &, const Entity &){}, 1);
//collision.onUpdate(entity, std::chrono::nanoseconds(1));
//collision.onFixedUpdate(entity);
//REQUIRE(entity.getComponent<PositionComponent>().position.x == 1);
//REQUIRE(entity.getComponent<PositionComponent>().position.y == 1);
//REQUIRE(entity.getComponent<PositionComponent>().position.z == 1);
}