mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-05-31 17:33:20 +00:00
Adding tests and cleaning up
This commit is contained in:
+1
-1
@@ -71,7 +71,7 @@ add_executable(unit_tests EXCLUDE_FROM_ALL
|
||||
tests/MainTest.cpp
|
||||
tests/EngineTests.cpp
|
||||
tests/CallbackTest.cpp
|
||||
)
|
||||
tests/MoveTests.cpp)
|
||||
target_include_directories(unit_tests PUBLIC sources)
|
||||
target_link_libraries(unit_tests PUBLIC wal ray)
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <Component/Movable/MovableComponent.hpp>
|
||||
#include <Component/Controllable/ControllableComponent.hpp>
|
||||
#include <Component/Keyboard/KeyboardComponent.hpp>
|
||||
#include <System/Gamepad/GamepadSystem.hpp>
|
||||
#include "Models/Vector2.hpp"
|
||||
#include "Component/Renderer/CameraComponent.hpp"
|
||||
#include "Runner.hpp"
|
||||
@@ -40,6 +41,7 @@ namespace BBM
|
||||
void addSystems(WAL::Wal &wal)
|
||||
{
|
||||
wal.addSystem<KeyboardSystem>()
|
||||
.addSystem<GamepadSystem>()
|
||||
.addSystem<ControllableSystem>()
|
||||
.addSystem<MovableSystem>();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
//
|
||||
// Created by Tom Augier on 2021-05-20.
|
||||
// Edited by Benjamin Henry on 2021-05-20.
|
||||
// Created by Arthur Jamet on 2021-05-31.
|
||||
//
|
||||
|
||||
#include "GamepadSystem.hpp"
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
//
|
||||
// Created by Tom Augier on 2021-05-20.
|
||||
// Edited by Benjamin Henry on 2021-05-20.
|
||||
// Created by Arthur Jamet on 2021-05-31.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
//
|
||||
// Created by Zoe Roux on 5/31/21.
|
||||
//
|
||||
|
||||
#include "Entity/Entity.hpp"
|
||||
#include "Component/Position/PositionComponent.hpp"
|
||||
#include "System/Movable/MovableSystem.hpp"
|
||||
#include "System/Controllable/ControllableSystem.hpp"
|
||||
#include <catch2/catch.hpp>
|
||||
#include <Wal.hpp>
|
||||
#include <Component/Controllable/ControllableComponent.hpp>
|
||||
|
||||
#define private public
|
||||
#include <Component/Movable/MovableComponent.hpp>
|
||||
|
||||
using namespace WAL;
|
||||
using namespace BBM;
|
||||
|
||||
|
||||
TEST_CASE("Move test", "[Component][System]")
|
||||
{
|
||||
Scene scene;
|
||||
scene.addEntity("player")
|
||||
.addComponent<ControllableComponent>()
|
||||
.addComponent<MovableComponent>()
|
||||
.addComponent<PositionComponent>();
|
||||
Entity &entity = scene.getEntities()[0];
|
||||
|
||||
REQUIRE(entity.getComponent<PositionComponent>().position == Vector3f());
|
||||
|
||||
entity.getComponent<ControllableComponent>().move = Vector2f(1, 1);
|
||||
|
||||
ControllableSystem controllable;
|
||||
controllable.onUpdate(entity, std::chrono::nanoseconds(1));
|
||||
controllable.onFixedUpdate(entity);
|
||||
REQUIRE(entity.getComponent<MovableComponent>()._acceleration.x > 0);
|
||||
REQUIRE(entity.getComponent<MovableComponent>()._acceleration.z > 0);
|
||||
|
||||
MovableSystem movable;
|
||||
movable.onUpdate(entity, std::chrono::nanoseconds(1));
|
||||
movable.onFixedUpdate(entity);
|
||||
REQUIRE(entity.getComponent<MovableComponent>()._velocity.x > 0);
|
||||
REQUIRE(entity.getComponent<MovableComponent>()._velocity.z > 0);
|
||||
REQUIRE(entity.getComponent<MovableComponent>()._acceleration.x == 0);
|
||||
REQUIRE(entity.getComponent<MovableComponent>()._acceleration.z == 0);
|
||||
movable.onUpdate(entity, std::chrono::nanoseconds(1));
|
||||
movable.onFixedUpdate(entity);
|
||||
REQUIRE(entity.getComponent<PositionComponent>().position.x > 0);
|
||||
REQUIRE(entity.getComponent<PositionComponent>().position.z > 0);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user