Add tests and SDK

This commit is contained in:
Jérôme Leclercq
2021-05-17 23:08:37 +02:00
parent 26de5872eb
commit e716b44aa3
52 changed files with 539 additions and 276 deletions

View File

@@ -1,11 +1,11 @@
#include <NazaraSDK/Application.hpp>
#include <NazaraSDK/ClientApplication.hpp>
#include <Catch/catch.hpp>
SCENARIO("Application", "[NDK][APPLICATION]")
{
GIVEN("An application")
{
Nz::Window& window = Ndk::Application::Instance()->AddWindow<Nz::Window>();
Nz::Window& window = Ndk::ClientApplication::Instance()->AddWindow<Nz::Window>();
WHEN("We open a window")
{
@@ -22,4 +22,4 @@ SCENARIO("Application", "[NDK][APPLICATION]")
}
}
}
}
}

View File

@@ -32,7 +32,7 @@ SCENARIO("BaseSystem", "[NDK][BASESYSTEM]")
{
GIVEN("Our TestSystem")
{
Ndk::World world(false);
Ndk::World world;
Ndk::BaseSystem& system = world.AddSystem<TestSystem>();
REQUIRE(&system.GetWorld() == &world);
@@ -62,4 +62,4 @@ SCENARIO("BaseSystem", "[NDK][BASESYSTEM]")
}
}
}
}
}

View File

@@ -55,7 +55,7 @@ SCENARIO("Entity", "[NDK][ENTITY]")
{
GIVEN("A world & an entity")
{
Ndk::World world(false);
Ndk::World world;
Ndk::BaseSystem& system = world.AddSystem<UpdateSystem>();
Ndk::EntityHandle entity = world.CreateEntity();
@@ -99,4 +99,4 @@ SCENARIO("Entity", "[NDK][ENTITY]")
}
}
}
}
}

View File

@@ -6,7 +6,7 @@ SCENARIO("EntityList", "[NDK][ENTITYLIST]")
{
GIVEN("A world & a set of entities")
{
Ndk::World world(false);
Ndk::World world;
const Ndk::EntityHandle& entity = world.CreateEntity();
Ndk::EntityList entityList;
@@ -39,4 +39,4 @@ SCENARIO("EntityList", "[NDK][ENTITYLIST]")
}
}
}
}
}

View File

@@ -6,7 +6,7 @@ SCENARIO("EntityOwner", "[NDK][ENTITYOWNER]")
{
GIVEN("A world & an entity")
{
Ndk::World world(false);
Ndk::World world;
Ndk::EntityHandle entity = world.CreateEntity();
WHEN("We set the ownership of the entity to our owner")
@@ -108,7 +108,7 @@ SCENARIO("EntityOwner", "[NDK][ENTITYOWNER]")
GIVEN("A vector of EntityOwner")
{
Ndk::World world(false);
Ndk::World world;
std::vector<Ndk::EntityOwner> entityOwners;
for (std::size_t i = 1; i <= 10; ++i)

View File

@@ -3,6 +3,7 @@
#include <NazaraSDK/Components/CollisionComponent2D.hpp>
#include <NazaraSDK/Components/NodeComponent.hpp>
#include <NazaraSDK/Components/PhysicsComponent2D.hpp>
#include <NazaraSDK/Systems/PhysicsSystem2D.hpp>
#include <Catch/catch.hpp>
#include <limits>
@@ -13,6 +14,7 @@ SCENARIO("PhysicsSystem2D", "[NDK][PHYSICSSYSTEM2D]")
GIVEN("A world and an entity")
{
Ndk::World world;
world.AddSystem<Ndk::PhysicsSystem2D>();
Nz::Vector2f position(2.f, 3.f);
Nz::Rectf movingAABB(0.f, 0.f, 16.f, 18.f);
@@ -74,6 +76,7 @@ SCENARIO("PhysicsSystem2D", "[NDK][PHYSICSSYSTEM2D]")
GIVEN("A world and a simple entity")
{
Ndk::World world;
world.AddSystem<Ndk::PhysicsSystem2D>();
Nz::Vector2f position(0.f, 0.f);
Nz::Rectf movingAABB(0.f, 0.f, 1.f, 2.f);
@@ -120,6 +123,7 @@ SCENARIO("PhysicsSystem2D", "[NDK][PHYSICSSYSTEM2D]")
GIVEN("A world and a simple entity not at the origin")
{
Ndk::World world;
world.AddSystem<Ndk::PhysicsSystem2D>();
Nz::Vector2f position(3.f, 4.f);
Nz::Rectf movingAABB(0.f, 0.f, 1.f, 2.f);

View File

@@ -3,6 +3,7 @@
#include <NazaraSDK/Components/CollisionComponent3D.hpp>
#include <NazaraSDK/Components/NodeComponent.hpp>
#include <NazaraSDK/Components/PhysicsComponent3D.hpp>
#include <NazaraSDK/Systems/PhysicsSystem3D.hpp>
#include <Catch/catch.hpp>
SCENARIO("PhysicsSystem3D", "[NDK][PHYSICSSYSTEM3D]")
@@ -10,6 +11,8 @@ SCENARIO("PhysicsSystem3D", "[NDK][PHYSICSSYSTEM3D]")
GIVEN("A world and a static entity & a dynamic entity")
{
Ndk::World world;
world.AddSystem<Ndk::PhysicsSystem3D>();
const Ndk::EntityHandle& staticEntity = world.CreateEntity();
Ndk::CollisionComponent3D& collisionComponentStatic = staticEntity->AddComponent<Ndk::CollisionComponent3D>();
Ndk::NodeComponent& nodeComponentStatic = staticEntity->AddComponent<Ndk::NodeComponent>();
@@ -31,4 +34,4 @@ SCENARIO("PhysicsSystem3D", "[NDK][PHYSICSSYSTEM3D]")
}
}
}
}
}

View File

@@ -13,7 +13,7 @@ SCENARIO("VelocitySystem", "[NDK][VELOCITYSYSTEM]")
Ndk::VelocityComponent& velocityComponent = entity->AddComponent<Ndk::VelocityComponent>();
Ndk::NodeComponent& nodeComponent = entity->AddComponent<Ndk::NodeComponent>();
world.GetSystem<Ndk::VelocitySystem>().SetFixedUpdateRate(30.f);
world.AddSystem<Ndk::VelocitySystem>().SetFixedUpdateRate(30.f);
WHEN("We give a speed to our entity")
{
@@ -27,4 +27,4 @@ SCENARIO("VelocitySystem", "[NDK][VELOCITYSYSTEM]")
}
}
}
}
}

View File

@@ -55,7 +55,7 @@ SCENARIO("World", "[NDK][WORLD]")
{
GIVEN("A brave new world and the update system")
{
Ndk::World world(false);
Ndk::World world;
Ndk::BaseSystem& system = world.AddSystem<UpdateSystem>();
WHEN("We had a new entity with an updatable component and a system")
@@ -103,7 +103,7 @@ SCENARIO("World", "[NDK][WORLD]")
GIVEN("A newly created entity")
{
Ndk::World world(false);
Ndk::World world;
Ndk::EntityHandle entity = world.CreateEntity();
REQUIRE(entity.IsValid());
@@ -129,7 +129,7 @@ SCENARIO("World", "[NDK][WORLD]")
GIVEN("An empty world")
{
Ndk::World world(false);
Ndk::World world;
WHEN("We create two entities")
{