aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-12-22 12:32:22 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-12-22 12:32:22 +0100
commit61148c757a1f742ff09e40e5347e74e638c7371c (patch)
treea2e40998981fa6f12430d2a1254250219f30d44f /src/test
parente2162171c7ab72f450f73a0908946aa4a4dee5ee (diff)
update clang-format optionsHEADmaster
Diffstat (limited to 'src/test')
-rw-r--r--src/test/AssetTest.cpp6
-rw-r--r--src/test/AudioTest.cpp6
-rw-r--r--src/test/CollisionTest.cpp83
-rw-r--r--src/test/ECSTest.cpp68
-rw-r--r--src/test/EventTest.cpp35
-rw-r--r--src/test/InputTest.cpp35
-rw-r--r--src/test/LoopManagerTest.cpp2
-rw-r--r--src/test/LoopTimerTest.cpp2
-rw-r--r--src/test/ParticleTest.cpp76
-rw-r--r--src/test/PhysicsTest.cpp10
-rw-r--r--src/test/Profiling.cpp91
-rw-r--r--src/test/RenderSystemTest.cpp92
-rw-r--r--src/test/ReplayManagerTest.cpp6
-rw-r--r--src/test/ResourceManagerTest.cpp6
-rw-r--r--src/test/SaveManagerTest.cpp4
-rw-r--r--src/test/SceneManagerTest.cpp20
-rw-r--r--src/test/ScriptSaveManagerTest.cpp4
-rw-r--r--src/test/ScriptSceneTest.cpp2
-rw-r--r--src/test/ScriptTest.h10
-rw-r--r--src/test/ValueBrokerTest.cpp4
20 files changed, 307 insertions, 255 deletions
diff --git a/src/test/AssetTest.cpp b/src/test/AssetTest.cpp
index 93fd6a9..f41e9de 100644
--- a/src/test/AssetTest.cpp
+++ b/src/test/AssetTest.cpp
@@ -7,15 +7,15 @@ using namespace std;
using namespace crepe;
using namespace testing;
-TEST(AssetTest, Existant) { ASSERT_NO_THROW(Asset{"asset/texture/img.png"}); }
+TEST(AssetTest, Existant) { ASSERT_NO_THROW(Asset {"asset/texture/img.png"}); }
-TEST(AssetTest, Nonexistant) { ASSERT_ANY_THROW(Asset{"asset/nonexistant"}); }
+TEST(AssetTest, Nonexistant) { ASSERT_ANY_THROW(Asset {"asset/nonexistant"}); }
TEST(AssetTest, Rootless) {
Config & cfg = Config::get_instance();
cfg.asset.root_pattern.clear();
string arbitrary = "\\/this is / /../passed through as-is";
- Asset asset{arbitrary};
+ Asset asset {arbitrary};
ASSERT_EQ(arbitrary, asset.get_path());
}
diff --git a/src/test/AudioTest.cpp b/src/test/AudioTest.cpp
index 415a12e..3844c73 100644
--- a/src/test/AudioTest.cpp
+++ b/src/test/AudioTest.cpp
@@ -31,11 +31,11 @@ private:
private:
Mediator mediator;
- ComponentManager component_manager{mediator};
- ResourceManager resource_manager{mediator};
+ ComponentManager component_manager {mediator};
+ ResourceManager resource_manager {mediator};
public:
- TestAudioSystem system{mediator};
+ TestAudioSystem system {mediator};
TestSoundContext & context = system.context;
private:
diff --git a/src/test/CollisionTest.cpp b/src/test/CollisionTest.cpp
index c8d804c..c571c1a 100644
--- a/src/test/CollisionTest.cpp
+++ b/src/test/CollisionTest.cpp
@@ -39,8 +39,9 @@ public:
}
void init() {
- subscribe<CollisionEvent>(
- [this](const CollisionEvent & ev) -> bool { return this->on_collision(ev); });
+ subscribe<CollisionEvent>([this](const CollisionEvent & ev) -> bool {
+ return this->on_collision(ev);
+ });
}
void update() {
// Retrieve component from the same GameObject this script is on
@@ -50,11 +51,11 @@ public:
class CollisionTest : public Test {
public:
Mediator m;
- EventManager event_mgr{m};
- ComponentManager mgr{m};
- CollisionSystem collision_sys{m};
- ScriptSystem script_sys{m};
- LoopTimerManager loop_timer{m};
+ EventManager event_mgr {m};
+ ComponentManager mgr {m};
+ CollisionSystem collision_sys {m};
+ ScriptSystem script_sys {m};
+ LoopTimerManager loop_timer {m};
GameObject world = mgr.new_object("world", "", {50, 50});
GameObject game_object1 = mgr.new_object("object1", "", {50, 50});
@@ -64,17 +65,17 @@ public:
CollisionHandler * script_object2_ref = nullptr;
void SetUp() override {
- world.add_component<Rigidbody>(Rigidbody::Data{
+ world.add_component<Rigidbody>(Rigidbody::Data {
// TODO: remove unrelated properties:
.body_type = Rigidbody::BodyType::STATIC,
});
// Create a box with an inner size of 10x10 units
- world.add_component<BoxCollider>(vec2{100, 100}, vec2{0, -100}); // Top
- world.add_component<BoxCollider>(vec2{100, 100}, vec2{0, 100}); // Bottom
- world.add_component<BoxCollider>(vec2{100, 100}, vec2{-100, 0}); // Left
- world.add_component<BoxCollider>(vec2{100, 100}, vec2{100, 0}); // right
+ world.add_component<BoxCollider>(vec2 {100, 100}, vec2 {0, -100}); // Top
+ world.add_component<BoxCollider>(vec2 {100, 100}, vec2 {0, 100}); // Bottom
+ world.add_component<BoxCollider>(vec2 {100, 100}, vec2 {-100, 0}); // Left
+ world.add_component<BoxCollider>(vec2 {100, 100}, vec2 {100, 0}); // right
- game_object1.add_component<Rigidbody>(Rigidbody::Data{
+ game_object1.add_component<Rigidbody>(Rigidbody::Data {
.mass = 1,
.gravity_scale = 0.01,
.body_type = Rigidbody::BodyType::DYNAMIC,
@@ -83,13 +84,13 @@ public:
.elasticity_coefficient = 1,
.collision_layers = {0},
});
- game_object1.add_component<BoxCollider>(vec2{10, 10}, vec2{0, 0});
+ game_object1.add_component<BoxCollider>(vec2 {10, 10}, vec2 {0, 0});
BehaviorScript & script_object1
= game_object1.add_component<BehaviorScript>().set_script<CollisionHandler>(1);
script_object1_ref = static_cast<CollisionHandler *>(script_object1.script.get());
ASSERT_NE(script_object1_ref, nullptr);
- game_object2.add_component<Rigidbody>(Rigidbody::Data{
+ game_object2.add_component<Rigidbody>(Rigidbody::Data {
.mass = 1,
.gravity_scale = 0.01,
.body_type = Rigidbody::BodyType::DYNAMIC,
@@ -98,7 +99,7 @@ public:
.elasticity_coefficient = 1,
.collision_layers = {0},
});
- game_object2.add_component<BoxCollider>(vec2{10, 10}, vec2{0, 0});
+ game_object2.add_component<BoxCollider>(vec2 {10, 10}, vec2 {0, 0});
BehaviorScript & script_object2
= game_object2.add_component<BehaviorScript>().set_script<CollisionHandler>(2);
script_object2_ref = static_cast<CollisionHandler *>(script_object2.script.get());
@@ -154,16 +155,18 @@ TEST_F(CollisionTest, collision_box_box_dynamic_x_direction_no_velocity) {
EXPECT_EQ(ev.info.self.transform.game_object_id, 1);
EXPECT_EQ(ev.info.resolution.x, -5);
EXPECT_EQ(ev.info.resolution.y, 0);
- EXPECT_EQ(ev.info.resolution_direction,
- crepe::CollisionSystem::Direction::X_DIRECTION);
+ EXPECT_EQ(
+ ev.info.resolution_direction, crepe::CollisionSystem::Direction::X_DIRECTION
+ );
};
script_object2_ref->test_fn = [&collision_happend](const CollisionEvent & ev) {
collision_happend = true;
EXPECT_EQ(ev.info.self.transform.game_object_id, 2);
EXPECT_EQ(ev.info.resolution.x, 5);
EXPECT_EQ(ev.info.resolution.y, 0);
- EXPECT_EQ(ev.info.resolution_direction,
- crepe::CollisionSystem::Direction::X_DIRECTION);
+ EXPECT_EQ(
+ ev.info.resolution_direction, crepe::CollisionSystem::Direction::X_DIRECTION
+ );
};
EXPECT_FALSE(collision_happend);
Transform & tf = this->mgr.get_components_by_id<Transform>(1).front().get();
@@ -179,16 +182,18 @@ TEST_F(CollisionTest, collision_box_box_dynamic_y_direction_no_velocity) {
EXPECT_EQ(ev.info.self.transform.game_object_id, 1);
EXPECT_EQ(ev.info.resolution.x, 0);
EXPECT_EQ(ev.info.resolution.y, -5);
- EXPECT_EQ(ev.info.resolution_direction,
- crepe::CollisionSystem::Direction::Y_DIRECTION);
+ EXPECT_EQ(
+ ev.info.resolution_direction, crepe::CollisionSystem::Direction::Y_DIRECTION
+ );
};
script_object2_ref->test_fn = [&collision_happend](const CollisionEvent & ev) {
collision_happend = true;
EXPECT_EQ(ev.info.self.transform.game_object_id, 2);
EXPECT_EQ(ev.info.resolution.x, 0);
EXPECT_EQ(ev.info.resolution.y, 5);
- EXPECT_EQ(ev.info.resolution_direction,
- crepe::CollisionSystem::Direction::Y_DIRECTION);
+ EXPECT_EQ(
+ ev.info.resolution_direction, crepe::CollisionSystem::Direction::Y_DIRECTION
+ );
};
EXPECT_FALSE(collision_happend);
Transform & tf = this->mgr.get_components_by_id<Transform>(1).front().get();
@@ -231,16 +236,18 @@ TEST_F(CollisionTest, collision_box_box_dynamic_x_direction) {
EXPECT_EQ(ev.info.self.transform.game_object_id, 1);
EXPECT_EQ(ev.info.resolution.x, -5);
EXPECT_EQ(ev.info.resolution.y, 5);
- EXPECT_EQ(ev.info.resolution_direction,
- crepe::CollisionSystem::Direction::X_DIRECTION);
+ EXPECT_EQ(
+ ev.info.resolution_direction, crepe::CollisionSystem::Direction::X_DIRECTION
+ );
};
script_object2_ref->test_fn = [&collision_happend](const CollisionEvent & ev) {
collision_happend = true;
EXPECT_EQ(ev.info.self.transform.game_object_id, 2);
EXPECT_EQ(ev.info.resolution.x, 5);
EXPECT_EQ(ev.info.resolution.y, -5);
- EXPECT_EQ(ev.info.resolution_direction,
- crepe::CollisionSystem::Direction::X_DIRECTION);
+ EXPECT_EQ(
+ ev.info.resolution_direction, crepe::CollisionSystem::Direction::X_DIRECTION
+ );
};
EXPECT_FALSE(collision_happend);
Transform & tf = this->mgr.get_components_by_id<Transform>(1).front().get();
@@ -260,16 +267,18 @@ TEST_F(CollisionTest, collision_box_box_dynamic_y_direction) {
EXPECT_EQ(ev.info.self.transform.game_object_id, 1);
EXPECT_EQ(ev.info.resolution.x, 5);
EXPECT_EQ(ev.info.resolution.y, -5);
- EXPECT_EQ(ev.info.resolution_direction,
- crepe::CollisionSystem::Direction::Y_DIRECTION);
+ EXPECT_EQ(
+ ev.info.resolution_direction, crepe::CollisionSystem::Direction::Y_DIRECTION
+ );
};
script_object2_ref->test_fn = [&collision_happend](const CollisionEvent & ev) {
collision_happend = true;
EXPECT_EQ(ev.info.self.transform.game_object_id, 2);
EXPECT_EQ(ev.info.resolution.x, -5);
EXPECT_EQ(ev.info.resolution.y, 5);
- EXPECT_EQ(ev.info.resolution_direction,
- crepe::CollisionSystem::Direction::Y_DIRECTION);
+ EXPECT_EQ(
+ ev.info.resolution_direction, crepe::CollisionSystem::Direction::Y_DIRECTION
+ );
};
EXPECT_FALSE(collision_happend);
Transform & tf = this->mgr.get_components_by_id<Transform>(1).front().get();
@@ -309,8 +318,9 @@ TEST_F(CollisionTest, collision_box_box_static_x_direction) {
EXPECT_EQ(ev.info.self.transform.game_object_id, 1);
EXPECT_EQ(ev.info.resolution.x, -5);
EXPECT_EQ(ev.info.resolution.y, 5);
- EXPECT_EQ(ev.info.resolution_direction,
- crepe::CollisionSystem::Direction::X_DIRECTION);
+ EXPECT_EQ(
+ ev.info.resolution_direction, crepe::CollisionSystem::Direction::X_DIRECTION
+ );
};
script_object2_ref->test_fn = [&collision_happend](const CollisionEvent & ev) {
// is static should not be called
@@ -334,8 +344,9 @@ TEST_F(CollisionTest, collision_box_box_static_y_direction) {
EXPECT_EQ(ev.info.self.transform.game_object_id, 1);
EXPECT_EQ(ev.info.resolution.x, 5);
EXPECT_EQ(ev.info.resolution.y, -5);
- EXPECT_EQ(ev.info.resolution_direction,
- crepe::CollisionSystem::Direction::Y_DIRECTION);
+ EXPECT_EQ(
+ ev.info.resolution_direction, crepe::CollisionSystem::Direction::Y_DIRECTION
+ );
};
script_object2_ref->test_fn = [&collision_happend](const CollisionEvent & ev) {
// is static should not be called
diff --git a/src/test/ECSTest.cpp b/src/test/ECSTest.cpp
index 8f86a91..92436a9 100644
--- a/src/test/ECSTest.cpp
+++ b/src/test/ECSTest.cpp
@@ -16,7 +16,7 @@ class ECSTest : public ::testing::Test {
Mediator m;
public:
- ComponentManager mgr{m};
+ ComponentManager mgr {m};
class TestComponent : public Component {
using Component::Component;
@@ -24,7 +24,7 @@ public:
};
TEST_F(ECSTest, createGameObject) {
- GameObject obj = mgr.new_object("body", "person", vec2{0, 0}, 0, 1);
+ GameObject obj = mgr.new_object("body", "person", vec2 {0, 0}, 0, 1);
vector<reference_wrapper<Metadata>> metadata = mgr.get_components_by_type<Metadata>();
vector<reference_wrapper<Transform>> transform = mgr.get_components_by_type<Transform>();
@@ -44,8 +44,8 @@ TEST_F(ECSTest, createGameObject) {
}
TEST_F(ECSTest, deleteAllGameObjects) {
- GameObject obj0 = mgr.new_object("body", "person", vec2{0, 0}, 0, 1);
- GameObject obj1 = mgr.new_object("body", "person", vec2{0, 0}, 0, 1);
+ GameObject obj0 = mgr.new_object("body", "person", vec2 {0, 0}, 0, 1);
+ GameObject obj1 = mgr.new_object("body", "person", vec2 {0, 0}, 0, 1);
mgr.delete_all_components();
@@ -55,7 +55,7 @@ TEST_F(ECSTest, deleteAllGameObjects) {
EXPECT_EQ(metadata.size(), 0);
EXPECT_EQ(transform.size(), 0);
- GameObject obj2 = mgr.new_object("body2", "person2", vec2{1, 0}, 5, 1);
+ GameObject obj2 = mgr.new_object("body2", "person2", vec2 {1, 0}, 5, 1);
metadata = mgr.get_components_by_type<Metadata>();
transform = mgr.get_components_by_type<Transform>();
@@ -77,8 +77,8 @@ TEST_F(ECSTest, deleteAllGameObjects) {
}
TEST_F(ECSTest, deleteGameObject) {
- GameObject obj0 = mgr.new_object("body", "person", vec2{0, 0}, 0, 1);
- GameObject obj1 = mgr.new_object("body", "person", vec2{0, 0}, 0, 1);
+ GameObject obj0 = mgr.new_object("body", "person", vec2 {0, 0}, 0, 1);
+ GameObject obj1 = mgr.new_object("body", "person", vec2 {0, 0}, 0, 1);
mgr.delete_all_components_of_id(0);
@@ -103,7 +103,7 @@ TEST_F(ECSTest, deleteGameObject) {
TEST_F(ECSTest, manyGameObjects) {
for (int i = 0; i < 5000; i++) {
- GameObject obj = mgr.new_object("body", "person", vec2{0, 0}, 0, i);
+ GameObject obj = mgr.new_object("body", "person", vec2 {0, 0}, 0, i);
}
vector<reference_wrapper<Metadata>> metadata = mgr.get_components_by_type<Metadata>();
@@ -135,7 +135,7 @@ TEST_F(ECSTest, manyGameObjects) {
for (int i = 0; i < 10000 - 5000; i++) {
string tag = "person" + to_string(i);
- GameObject obj = mgr.new_object("body", tag, vec2{0, 0}, i, 0);
+ GameObject obj = mgr.new_object("body", tag, vec2 {0, 0}, i, 0);
}
metadata = mgr.get_components_by_type<Metadata>();
@@ -168,7 +168,7 @@ TEST_F(ECSTest, manyGameObjects) {
for (int i = 0; i < 10000; i++) {
string name = "body" + to_string(i);
- GameObject obj = mgr.new_object(name, "person", vec2{0, 0}, 0, 0);
+ GameObject obj = mgr.new_object(name, "person", vec2 {0, 0}, 0, 0);
}
metadata = mgr.get_components_by_type<Metadata>();
@@ -193,8 +193,8 @@ TEST_F(ECSTest, manyGameObjects) {
}
TEST_F(ECSTest, getComponentsByID) {
- GameObject obj0 = mgr.new_object("body", "person", vec2{0, 0}, 0, 1);
- GameObject obj1 = mgr.new_object("body", "person", vec2{0, 0}, 0, 1);
+ GameObject obj0 = mgr.new_object("body", "person", vec2 {0, 0}, 0, 1);
+ GameObject obj1 = mgr.new_object("body", "person", vec2 {0, 0}, 0, 1);
vector<reference_wrapper<Metadata>> metadata = mgr.get_components_by_id<Metadata>(0);
vector<reference_wrapper<Transform>> transform = mgr.get_components_by_id<Transform>(1);
@@ -217,19 +217,21 @@ TEST_F(ECSTest, getComponentsByID) {
TEST_F(ECSTest, tooMuchComponents) {
try {
- GameObject obj0 = mgr.new_object("body", "person", vec2{0, 0}, 0, 1);
- obj0.add_component<Transform>(vec2{10, 10}, 0, 1);
+ GameObject obj0 = mgr.new_object("body", "person", vec2 {0, 0}, 0, 1);
+ obj0.add_component<Transform>(vec2 {10, 10}, 0, 1);
} catch (const exception & e) {
- EXPECT_EQ(e.what(),
- string("Exceeded maximum number of instances for this component type"));
+ EXPECT_EQ(
+ e.what(), string("Exceeded maximum number of instances for this component type")
+ );
}
try {
- GameObject obj1 = mgr.new_object("body", "person", vec2{0, 0}, 0, 1);
+ GameObject obj1 = mgr.new_object("body", "person", vec2 {0, 0}, 0, 1);
obj1.add_component<Metadata>("body", "person");
} catch (const exception & e) {
- EXPECT_EQ(e.what(),
- string("Exceeded maximum number of instances for this component type"));
+ EXPECT_EQ(
+ e.what(), string("Exceeded maximum number of instances for this component type")
+ );
}
vector<reference_wrapper<Metadata>> metadata = mgr.get_components_by_type<Metadata>();
@@ -241,11 +243,11 @@ TEST_F(ECSTest, tooMuchComponents) {
TEST_F(ECSTest, partentChild) {
{
- GameObject body = mgr.new_object("body", "person", vec2{0, 0}, 0, 1);
- GameObject right_leg = mgr.new_object("rightLeg", "person", vec2{1, 1}, 0, 1);
- GameObject left_leg = mgr.new_object("leftLeg", "person", vec2{1, 1}, 0, 1);
- GameObject right_foot = mgr.new_object("rightFoot", "person", vec2{2, 2}, 0, 1);
- GameObject left_foot = mgr.new_object("leftFoot", "person", vec2{2, 2}, 0, 1);
+ GameObject body = mgr.new_object("body", "person", vec2 {0, 0}, 0, 1);
+ GameObject right_leg = mgr.new_object("rightLeg", "person", vec2 {1, 1}, 0, 1);
+ GameObject left_leg = mgr.new_object("leftLeg", "person", vec2 {1, 1}, 0, 1);
+ GameObject right_foot = mgr.new_object("rightFoot", "person", vec2 {2, 2}, 0, 1);
+ GameObject left_foot = mgr.new_object("leftFoot", "person", vec2 {2, 2}, 0, 1);
// Set the parent of each GameObject
right_foot.set_parent(right_leg);
@@ -290,10 +292,10 @@ TEST_F(ECSTest, partentChild) {
}
TEST_F(ECSTest, persistent) {
- GameObject obj0 = mgr.new_object("obj0", "obj0", vec2{0, 0}, 0, 1);
- GameObject obj1 = mgr.new_object("obj1", "obj1", vec2{0, 0}, 0, 1);
+ GameObject obj0 = mgr.new_object("obj0", "obj0", vec2 {0, 0}, 0, 1);
+ GameObject obj1 = mgr.new_object("obj1", "obj1", vec2 {0, 0}, 0, 1);
obj1.set_persistent();
- GameObject obj2 = mgr.new_object("obj2", "obj2", vec2{0, 0}, 0, 1);
+ GameObject obj2 = mgr.new_object("obj2", "obj2", vec2 {0, 0}, 0, 1);
vector<reference_wrapper<Metadata>> metadata = mgr.get_components_by_type<Metadata>();
vector<reference_wrapper<Transform>> transform = mgr.get_components_by_type<Transform>();
@@ -329,8 +331,8 @@ TEST_F(ECSTest, persistent) {
EXPECT_EQ(transform[0].get().position.x, 0);
EXPECT_EQ(transform[0].get().position.y, 0);
- GameObject obj3 = mgr.new_object("obj3", "obj3", vec2{0, 0}, 0, 5);
- GameObject obj4 = mgr.new_object("obj4", "obj4", vec2{0, 0}, 0, 5);
+ GameObject obj3 = mgr.new_object("obj3", "obj3", vec2 {0, 0}, 0, 5);
+ GameObject obj4 = mgr.new_object("obj4", "obj4", vec2 {0, 0}, 0, 5);
metadata = mgr.get_components_by_type<Metadata>();
transform = mgr.get_components_by_type<Transform>();
@@ -358,10 +360,10 @@ TEST_F(ECSTest, persistent) {
}
TEST_F(ECSTest, resetPersistent) {
- GameObject obj0 = mgr.new_object("obj0", "obj0", vec2{0, 0}, 0, 1);
- GameObject obj1 = mgr.new_object("obj1", "obj1", vec2{0, 0}, 0, 1);
+ GameObject obj0 = mgr.new_object("obj0", "obj0", vec2 {0, 0}, 0, 1);
+ GameObject obj1 = mgr.new_object("obj1", "obj1", vec2 {0, 0}, 0, 1);
obj1.set_persistent();
- GameObject obj2 = mgr.new_object("obj2", "obj2", vec2{0, 0}, 0, 1);
+ GameObject obj2 = mgr.new_object("obj2", "obj2", vec2 {0, 0}, 0, 1);
vector<reference_wrapper<Metadata>> metadata = mgr.get_components_by_type<Metadata>();
vector<reference_wrapper<Transform>> transform = mgr.get_components_by_type<Transform>();
@@ -478,5 +480,5 @@ TEST_F(ECSTest, Snapshot) {
mgr.restore(snapshot);
- EXPECT_EQ(foo.transform.position, (vec2{1, 1}));
+ EXPECT_EQ(foo.transform.position, (vec2 {1, 1}));
}
diff --git a/src/test/EventTest.cpp b/src/test/EventTest.cpp
index f8be3fe..6105679 100644
--- a/src/test/EventTest.cpp
+++ b/src/test/EventTest.cpp
@@ -10,7 +10,7 @@ using namespace crepe;
class EventManagerTest : public ::testing::Test {
protected:
Mediator mediator;
- EventManager event_mgr{mediator};
+ EventManager event_mgr {mediator};
void SetUp() override {
// Clear any existing subscriptions or events before each test
event_mgr.clear();
@@ -30,18 +30,20 @@ TEST_F(EventManagerTest, EventSubscription) {
// Verify subscription (not directly verifiable; test by triggering event)
event_mgr.trigger_event<KeyPressEvent>(
- KeyPressEvent{
+ KeyPressEvent {
.repeat = true,
.key = Keycode::A,
},
- 1);
+ 1
+ );
event_mgr.trigger_event<KeyPressEvent>(
- KeyPressEvent{
+ KeyPressEvent {
.repeat = true,
.key = Keycode::A,
},
- EventManager::CHANNEL_ALL);
+ EventManager::CHANNEL_ALL
+ );
}
TEST_F(EventManagerTest, EventManagerTest_trigger_all_channels) {
bool triggered = false;
@@ -55,7 +57,7 @@ TEST_F(EventManagerTest, EventManagerTest_trigger_all_channels) {
};
event_mgr.subscribe<MouseClickEvent>(mouse_handler, EventManager::CHANNEL_ALL);
- MouseClickEvent click_event{.mouse_pos = {100, 200}, .button = MouseButton::LEFT_MOUSE};
+ MouseClickEvent click_event {.mouse_pos = {100, 200}, .button = MouseButton::LEFT_MOUSE};
event_mgr.trigger_event<MouseClickEvent>(click_event, EventManager::CHANNEL_ALL);
EXPECT_TRUE(triggered);
@@ -72,7 +74,7 @@ TEST_F(EventManagerTest, EventManagerTest_trigger_one_channel) {
};
event_mgr.subscribe<MouseClickEvent>(mouse_handler, test_channel);
- MouseClickEvent click_event{.mouse_pos = {100, 200}, .button = MouseButton::LEFT_MOUSE};
+ MouseClickEvent click_event {.mouse_pos = {100, 200}, .button = MouseButton::LEFT_MOUSE};
event_mgr.trigger_event<MouseClickEvent>(click_event, EventManager::CHANNEL_ALL);
EXPECT_FALSE(triggered);
@@ -103,7 +105,7 @@ TEST_F(EventManagerTest, EventManagerTest_callback_propagation) {
};
// Test event
- MouseClickEvent click_event{.mouse_pos = {100, 200}, .button = MouseButton::LEFT_MOUSE};
+ MouseClickEvent click_event {.mouse_pos = {100, 200}, .button = MouseButton::LEFT_MOUSE};
event_mgr.subscribe<MouseClickEvent>(mouse_handler_true, EventManager::CHANNEL_ALL);
event_mgr.subscribe<MouseClickEvent>(mouse_handler_false, EventManager::CHANNEL_ALL);
@@ -151,10 +153,12 @@ TEST_F(EventManagerTest, EventManagerTest_queue_dispatch) {
event_mgr.subscribe<MouseClickEvent>(mouse_handler2, test_channel);
event_mgr.queue_event<MouseClickEvent>(
- MouseClickEvent{.mouse_pos = {100, 200}, .button = MouseButton::LEFT_MOUSE});
+ MouseClickEvent {.mouse_pos = {100, 200}, .button = MouseButton::LEFT_MOUSE}
+ );
event_mgr.queue_event<MouseClickEvent>(
- MouseClickEvent{.mouse_pos = {100, 200}, .button = MouseButton::LEFT_MOUSE},
- test_channel);
+ MouseClickEvent {.mouse_pos = {100, 200}, .button = MouseButton::LEFT_MOUSE},
+ test_channel
+ );
event_mgr.dispatch_events();
EXPECT_TRUE(triggered1);
EXPECT_TRUE(triggered2);
@@ -188,7 +192,8 @@ TEST_F(EventManagerTest, EventManagerTest_unsubscribe) {
// Queue events
event_mgr.queue_event<MouseClickEvent>(
- MouseClickEvent{.mouse_pos = {100, 200}, .button = MouseButton::LEFT_MOUSE});
+ MouseClickEvent {.mouse_pos = {100, 200}, .button = MouseButton::LEFT_MOUSE}
+ );
// Dispatch events - both handlers should be triggered
event_mgr.dispatch_events();
@@ -204,7 +209,8 @@ TEST_F(EventManagerTest, EventManagerTest_unsubscribe) {
// Queue the same event again
event_mgr.queue_event<MouseClickEvent>(
- MouseClickEvent{.mouse_pos = {100, 200}, .button = MouseButton::LEFT_MOUSE});
+ MouseClickEvent {.mouse_pos = {100, 200}, .button = MouseButton::LEFT_MOUSE}
+ );
// Dispatch events - only handler 2 should be triggered, handler 1 should NOT
event_mgr.dispatch_events();
@@ -219,7 +225,8 @@ TEST_F(EventManagerTest, EventManagerTest_unsubscribe) {
// Queue the event again
event_mgr.queue_event<MouseClickEvent>(
- MouseClickEvent{.mouse_pos = {100, 200}, .button = MouseButton::LEFT_MOUSE});
+ MouseClickEvent {.mouse_pos = {100, 200}, .button = MouseButton::LEFT_MOUSE}
+ );
// Dispatch events - no handler should be triggered
event_mgr.dispatch_events();
diff --git a/src/test/InputTest.cpp b/src/test/InputTest.cpp
index 0243bd8..9a541a0 100644
--- a/src/test/InputTest.cpp
+++ b/src/test/InputTest.cpp
@@ -28,22 +28,23 @@ using namespace crepe;
class InputTest : public ::testing::Test {
public:
Mediator mediator;
- ComponentManager mgr{mediator};
- SDLContext sdl_context{mediator};
+ ComponentManager mgr {mediator};
+ SDLContext sdl_context {mediator};
- InputSystem input_system{mediator};
- ResourceManager resman{mediator};
- RenderSystem render{mediator};
- EventManager event_manager{mediator};
+ InputSystem input_system {mediator};
+ ResourceManager resman {mediator};
+ RenderSystem render {mediator};
+ EventManager event_manager {mediator};
//GameObject camera;
vec2 offset = {100, 200};
protected:
void SetUp() override {
GameObject obj = mgr.new_object("camera", "camera", offset, 0, 1);
- auto & camera
- = obj.add_component<Camera>(ivec2{500, 500}, vec2{500, 500},
- Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f});
+ auto & camera = obj.add_component<Camera>(
+ ivec2 {500, 500}, vec2 {500, 500},
+ Camera::Data {.bg_color = Color::WHITE, .zoom = 1.0f}
+ );
render.frame_update();
//mediator.event_manager = event_manager;
//mediator.component_manager = mgr;
@@ -208,14 +209,14 @@ TEST_F(InputTest, MouseClick) {
}
TEST_F(InputTest, testButtonClick) {
- GameObject button_obj = mgr.new_object("body", "person", vec2{0, 0}, 0, 1);
+ GameObject button_obj = mgr.new_object("body", "person", vec2 {0, 0}, 0, 1);
bool button_clicked = false;
event_manager.subscribe<ButtonPressEvent>([&](const ButtonPressEvent & event) {
button_clicked = true;
EXPECT_EQ(event.metadata.game_object_id, button_obj.id);
return false;
});
- auto & button = button_obj.add_component<Button>(vec2{100, 100}, vec2{0, 0});
+ auto & button = button_obj.add_component<Button>(vec2 {100, 100}, vec2 {0, 0});
bool hover = false;
button.active = true;
@@ -230,14 +231,14 @@ TEST_F(InputTest, testButtonClick) {
EXPECT_TRUE(button_clicked);
}
TEST_F(InputTest, buttonPositionCamera) {
- GameObject button_obj = mgr.new_object("body", "person", vec2{50, 50}, 0, 1);
+ GameObject button_obj = mgr.new_object("body", "person", vec2 {50, 50}, 0, 1);
bool button_clicked = false;
event_manager.subscribe<ButtonPressEvent>([&](const ButtonPressEvent & event) {
button_clicked = true;
EXPECT_EQ(event.metadata.game_object_id, button_obj.id);
return false;
});
- auto & button = button_obj.add_component<Button>(vec2{10, 10}, vec2{0, 0});
+ auto & button = button_obj.add_component<Button>(vec2 {10, 10}, vec2 {0, 0});
button.world_space = false;
bool hover = false;
@@ -253,14 +254,14 @@ TEST_F(InputTest, buttonPositionCamera) {
EXPECT_TRUE(button_clicked);
}
TEST_F(InputTest, buttonPositionWorld) {
- GameObject button_obj = mgr.new_object("body", "person", vec2{50, 50}, 0, 1);
+ GameObject button_obj = mgr.new_object("body", "person", vec2 {50, 50}, 0, 1);
bool button_clicked = false;
event_manager.subscribe<ButtonPressEvent>([&](const ButtonPressEvent & event) {
button_clicked = true;
EXPECT_EQ(event.metadata.game_object_id, button_obj.id);
return false;
});
- auto & button = button_obj.add_component<Button>(vec2{10, 10}, vec2{0, 0});
+ auto & button = button_obj.add_component<Button>(vec2 {10, 10}, vec2 {0, 0});
button.world_space = true;
bool hover = false;
button.active = true;
@@ -275,7 +276,7 @@ TEST_F(InputTest, buttonPositionWorld) {
EXPECT_FALSE(button_clicked);
}
TEST_F(InputTest, testButtonHover) {
- GameObject button_obj = mgr.new_object("body", "person", vec2{0, 0}, 0, 1);
+ GameObject button_obj = mgr.new_object("body", "person", vec2 {0, 0}, 0, 1);
bool button_hover = false;
event_manager.subscribe<ButtonEnterEvent>([&](const ButtonEnterEvent & event) {
button_hover = true;
@@ -287,7 +288,7 @@ TEST_F(InputTest, testButtonHover) {
EXPECT_EQ(event.metadata.game_object_id, button_obj.id);
return false;
});
- auto & button = button_obj.add_component<Button>(vec2{100, 100}, vec2{0, 0});
+ auto & button = button_obj.add_component<Button>(vec2 {100, 100}, vec2 {0, 0});
button.active = true;
// Mouse on button
SDL_Event hover_event;
diff --git a/src/test/LoopManagerTest.cpp b/src/test/LoopManagerTest.cpp
index f6653fa..302d96c 100644
--- a/src/test/LoopManagerTest.cpp
+++ b/src/test/LoopManagerTest.cpp
@@ -72,7 +72,7 @@ TEST_F(DISABLED_LoopManagerTest, ShutDown) {
// Start the loop in a separate thread
std::thread loop_thread([&]() { test_loop.start(); });
std::this_thread::sleep_for(std::chrono::milliseconds(1));
- test_loop.event_manager.trigger_event<ShutDownEvent>(ShutDownEvent{});
+ test_loop.event_manager.trigger_event<ShutDownEvent>(ShutDownEvent {});
// Wait for the loop thread to finish
loop_thread.join();
}
diff --git a/src/test/LoopTimerTest.cpp b/src/test/LoopTimerTest.cpp
index 7bd6305..52e412e 100644
--- a/src/test/LoopTimerTest.cpp
+++ b/src/test/LoopTimerTest.cpp
@@ -14,7 +14,7 @@ using namespace crepe;
class LoopTimerTest : public ::testing::Test {
protected:
Mediator mediator;
- LoopTimerManager loop_timer{mediator};
+ LoopTimerManager loop_timer {mediator};
void SetUp() override { loop_timer.start(); }
};
diff --git a/src/test/ParticleTest.cpp b/src/test/ParticleTest.cpp
index 7a731a3..eee7a73 100644
--- a/src/test/ParticleTest.cpp
+++ b/src/test/ParticleTest.cpp
@@ -22,45 +22,49 @@ class ParticlesTest : public ::testing::Test {
Mediator m;
public:
- ComponentManager component_manager{m};
- ParticleSystem particle_system{m};
- LoopTimerManager loop_timer{m};
+ ComponentManager component_manager {m};
+ ParticleSystem particle_system {m};
+ LoopTimerManager loop_timer {m};
void SetUp() override {
ComponentManager & mgr = this->component_manager;
std::vector<std::reference_wrapper<Transform>> transforms
= mgr.get_components_by_id<Transform>(0);
if (transforms.empty()) {
- GameObject game_object = mgr.new_object("", "", vec2{0, 0}, 0, 0);
+ GameObject game_object = mgr.new_object("", "", vec2 {0, 0}, 0, 0);
Color color(0, 0, 0, 0);
auto s1 = Asset("asset/texture/img.png");
Sprite & test_sprite = game_object.add_component<Sprite>(
- s1, Sprite::Data{
- .color = color,
- .flip = Sprite::FlipSettings{true, true},
- .size = {10, 10},
- });
+ s1,
+ Sprite::Data {
+ .color = color,
+ .flip = Sprite::FlipSettings {true, true},
+ .size = {10, 10},
+ }
+ );
- game_object.add_component<ParticleEmitter>(test_sprite,
- ParticleEmitter::Data{
- .offset = {0, 0},
- .max_particles = 100,
- .emission_rate = 0,
- .min_speed = 0,
- .max_speed = 0,
- .min_angle = 0,
- .max_angle = 0,
- .begin_lifespan = 0,
- .end_lifespan = 0,
- .force_over_time = vec2{0, 0},
- .boundary{
- .width = 0,
- .height = 0,
- .offset = vec2{0, 0},
- .reset_on_exit = false,
- },
- });
+ game_object.add_component<ParticleEmitter>(
+ test_sprite,
+ ParticleEmitter::Data {
+ .offset = {0, 0},
+ .max_particles = 100,
+ .emission_rate = 0,
+ .min_speed = 0,
+ .max_speed = 0,
+ .min_angle = 0,
+ .max_angle = 0,
+ .begin_lifespan = 0,
+ .end_lifespan = 0,
+ .force_over_time = vec2 {0, 0},
+ .boundary {
+ .width = 0,
+ .height = 0,
+ .offset = vec2 {0, 0},
+ .reset_on_exit = false,
+ },
+ }
+ );
}
transforms = mgr.get_components_by_id<Transform>(0);
Transform & transform = transforms.front().get();
@@ -78,8 +82,8 @@ public:
emitter.data.max_angle = 0;
emitter.data.begin_lifespan = 0;
emitter.data.end_lifespan = 0;
- emitter.data.force_over_time = vec2{0, 0};
- emitter.data.boundary = {0, 0, vec2{0, 0}, false};
+ emitter.data.force_over_time = vec2 {0, 0};
+ emitter.data.boundary = {0, 0, vec2 {0, 0}, false};
for (auto & particle : emitter.particles) {
particle.active = false;
}
@@ -204,9 +208,13 @@ TEST_F(ParticlesTest, boundaryParticleStop) {
EXPECT_NEAR(emitter.particles[0].velocity.x, 0, TOLERANCE);
EXPECT_NEAR(emitter.particles[0].velocity.y, 0, TOLERANCE);
if (emitter.particles[0].velocity.x != 0)
- EXPECT_NEAR(std::abs(emitter.particles[0].position.x),
- emitter.data.boundary.height / 2, TOLERANCE);
+ EXPECT_NEAR(
+ std::abs(emitter.particles[0].position.x), emitter.data.boundary.height / 2,
+ TOLERANCE
+ );
if (emitter.particles[0].velocity.y != 0)
- EXPECT_NEAR(std::abs(emitter.particles[0].position.y), emitter.data.boundary.width / 2,
- TOLERANCE);
+ EXPECT_NEAR(
+ std::abs(emitter.particles[0].position.y), emitter.data.boundary.width / 2,
+ TOLERANCE
+ );
}
diff --git a/src/test/PhysicsTest.cpp b/src/test/PhysicsTest.cpp
index 79ed0b8..85eb6d5 100644
--- a/src/test/PhysicsTest.cpp
+++ b/src/test/PhysicsTest.cpp
@@ -16,17 +16,17 @@ class PhysicsTest : public ::testing::Test {
Mediator m;
public:
- ComponentManager component_manager{m};
- PhysicsSystem system{m};
- LoopTimerManager loop_timer{m};
+ ComponentManager component_manager {m};
+ PhysicsSystem system {m};
+ LoopTimerManager loop_timer {m};
void SetUp() override {
ComponentManager & mgr = this->component_manager;
vector<reference_wrapper<Transform>> transforms
= mgr.get_components_by_id<Transform>(0);
if (transforms.empty()) {
- auto entity = mgr.new_object("", "", vec2{0, 0}, 0, 0);
- entity.add_component<Rigidbody>(Rigidbody::Data{
+ auto entity = mgr.new_object("", "", vec2 {0, 0}, 0, 0);
+ entity.add_component<Rigidbody>(Rigidbody::Data {
.mass = 1,
.gravity_scale = 1,
.body_type = Rigidbody::BodyType::DYNAMIC,
diff --git a/src/test/Profiling.cpp b/src/test/Profiling.cpp
index d1da5a0..d8bd09d 100644
--- a/src/test/Profiling.cpp
+++ b/src/test/Profiling.cpp
@@ -36,8 +36,9 @@ class TestScript : public Script {
return true;
}
void init() {
- subscribe<CollisionEvent>(
- [this](const CollisionEvent & ev) -> bool { return this->oncollision(ev); });
+ subscribe<CollisionEvent>([this](const CollisionEvent & ev) -> bool {
+ return this->oncollision(ev);
+ });
}
void fixed_update() {
// Retrieve component from the same GameObject this script is on
@@ -57,17 +58,17 @@ public:
const std::chrono::microseconds duration = 16000us;
Mediator m;
- SDLContext sdl_context{m};
- ResourceManager resman{m};
- ComponentManager mgr{m};
+ SDLContext sdl_context {m};
+ ResourceManager resman {m};
+ ComponentManager mgr {m};
// Add system used for profling tests
- EventManager evmgr{m};
- LoopTimerManager loopmgr{m};
- CollisionSystem collision_sys{m};
- PhysicsSystem physics_sys{m};
- ParticleSystem particle_sys{m};
- RenderSystem render_sys{m};
- ScriptSystem script_sys{m};
+ EventManager evmgr {m};
+ LoopTimerManager loopmgr {m};
+ CollisionSystem collision_sys {m};
+ PhysicsSystem physics_sys {m};
+ ParticleSystem particle_sys {m};
+ RenderSystem render_sys {m};
+ ScriptSystem script_sys {m};
// Test data
std::map<std::string, std::chrono::microseconds> timings;
@@ -77,11 +78,13 @@ public:
void SetUp() override {
GameObject do_not_use = mgr.new_object("DO_NOT_USE", "", {0, 0});
- do_not_use.add_component<Camera>(ivec2{1080, 720}, vec2{2000, 2000},
- Camera::Data{
- .bg_color = Color::WHITE,
- .zoom = 1.0f,
- });
+ do_not_use.add_component<Camera>(
+ ivec2 {1080, 720}, vec2 {2000, 2000},
+ Camera::Data {
+ .bg_color = Color::WHITE,
+ .zoom = 1.0f,
+ }
+ );
// initialize systems here:
//calls init
script_sys.fixed_update();
@@ -168,23 +171,25 @@ TEST_F(DISABLED_ProfilingTest, Profiling_2) {
{
//define gameobject used for testing
GameObject gameobject = mgr.new_object(
- "gameobject", "", {static_cast<float>(game_object_count * 2), 0});
- gameobject.add_component<Rigidbody>(Rigidbody::Data{
+ "gameobject", "", {static_cast<float>(game_object_count * 2), 0}
+ );
+ gameobject.add_component<Rigidbody>(Rigidbody::Data {
.gravity_scale = 0.0,
.body_type = Rigidbody::BodyType::STATIC,
});
- gameobject.add_component<BoxCollider>(vec2{0, 0}, vec2{1, 1});
+ gameobject.add_component<BoxCollider>(vec2 {0, 0}, vec2 {1, 1});
gameobject.add_component<BehaviorScript>().set_script<TestScript>();
Sprite & test_sprite = gameobject.add_component<Sprite>(
- Asset{"asset/texture/square.png"},
- Sprite::Data{
+ Asset {"asset/texture/square.png"},
+ Sprite::Data {
.color = {0, 0, 0, 0},
.flip = {.flip_x = false, .flip_y = false},
.sorting_in_layer = 1,
.order_in_layer = 1,
.size = {.y = 500},
- });
+ }
+ );
}
this->game_object_count++;
@@ -207,35 +212,39 @@ TEST_F(DISABLED_ProfilingTest, Profiling_3) {
{
//define gameobject used for testing
GameObject gameobject = mgr.new_object(
- "gameobject", "", {static_cast<float>(game_object_count * 2), 0});
- gameobject.add_component<Rigidbody>(Rigidbody::Data{
+ "gameobject", "", {static_cast<float>(game_object_count * 2), 0}
+ );
+ gameobject.add_component<Rigidbody>(Rigidbody::Data {
.gravity_scale = 0,
.body_type = Rigidbody::BodyType::STATIC,
});
- gameobject.add_component<BoxCollider>(vec2{0, 0}, vec2{1, 1});
+ gameobject.add_component<BoxCollider>(vec2 {0, 0}, vec2 {1, 1});
gameobject.add_component<BehaviorScript>().set_script<TestScript>();
Sprite & test_sprite = gameobject.add_component<Sprite>(
- Asset{"asset/texture/square.png"},
- Sprite::Data{
+ Asset {"asset/texture/square.png"},
+ Sprite::Data {
.color = {0, 0, 0, 0},
.flip = {.flip_x = false, .flip_y = false},
.sorting_in_layer = 1,
.order_in_layer = 1,
.size = {.y = 500},
- });
+ }
+ );
auto & test = gameobject.add_component<ParticleEmitter>(
- test_sprite, ParticleEmitter::Data{
- .max_particles = 10,
- .emission_rate = 100,
- .end_lifespan = 100000,
- .boundary{
- .width = 1000,
- .height = 1000,
- .offset = vec2{0, 0},
- .reset_on_exit = false,
- },
-
- });
+ test_sprite,
+ ParticleEmitter::Data {
+ .max_particles = 10,
+ .emission_rate = 100,
+ .end_lifespan = 100000,
+ .boundary {
+ .width = 1000,
+ .height = 1000,
+ .offset = vec2 {0, 0},
+ .reset_on_exit = false,
+ },
+
+ }
+ );
}
render_sys.frame_update();
this->game_object_count++;
diff --git a/src/test/RenderSystemTest.cpp b/src/test/RenderSystemTest.cpp
index 689a6d4..bdd87ee 100644
--- a/src/test/RenderSystemTest.cpp
+++ b/src/test/RenderSystemTest.cpp
@@ -26,10 +26,10 @@ class RenderSystemTest : public Test {
Mediator m;
public:
- ComponentManager mgr{m};
- SDLContext ctx{m};
- ResourceManager resource_manager{m};
- RenderSystem sys{m};
+ ComponentManager mgr {m};
+ SDLContext ctx {m};
+ ResourceManager resource_manager {m};
+ RenderSystem sys {m};
GameObject entity1 = this->mgr.new_object("name");
GameObject entity2 = this->mgr.new_object("name");
GameObject entity3 = this->mgr.new_object("name");
@@ -40,44 +40,52 @@ public:
auto s2 = Asset("asset/texture/img.png");
auto s3 = Asset("asset/texture/img.png");
auto s4 = Asset("asset/texture/img.png");
- auto & sprite1
- = entity1.add_component<Sprite>(s1, Sprite::Data{
- .color = Color(0, 0, 0, 0),
- .flip = Sprite::FlipSettings{false, false},
- .sorting_in_layer = 5,
- .order_in_layer = 5,
- .size = {10, 10},
- });
+ auto & sprite1 = entity1.add_component<Sprite>(
+ s1,
+ Sprite::Data {
+ .color = Color(0, 0, 0, 0),
+ .flip = Sprite::FlipSettings {false, false},
+ .sorting_in_layer = 5,
+ .order_in_layer = 5,
+ .size = {10, 10},
+ }
+ );
EXPECT_EQ(sprite1.data.order_in_layer, 5);
EXPECT_EQ(sprite1.data.sorting_in_layer, 5);
- auto & sprite2
- = entity2.add_component<Sprite>(s2, Sprite::Data{
- .color = Color(0, 0, 0, 0),
- .flip = Sprite::FlipSettings{false, false},
- .sorting_in_layer = 2,
- .order_in_layer = 1,
- });
+ auto & sprite2 = entity2.add_component<Sprite>(
+ s2,
+ Sprite::Data {
+ .color = Color(0, 0, 0, 0),
+ .flip = Sprite::FlipSettings {false, false},
+ .sorting_in_layer = 2,
+ .order_in_layer = 1,
+ }
+ );
EXPECT_EQ(sprite2.data.sorting_in_layer, 2);
EXPECT_EQ(sprite2.data.order_in_layer, 1);
- auto & sprite3
- = entity3.add_component<Sprite>(s3, Sprite::Data{
- .color = Color(0, 0, 0, 0),
- .flip = Sprite::FlipSettings{false, false},
- .sorting_in_layer = 1,
- .order_in_layer = 2,
- });
+ auto & sprite3 = entity3.add_component<Sprite>(
+ s3,
+ Sprite::Data {
+ .color = Color(0, 0, 0, 0),
+ .flip = Sprite::FlipSettings {false, false},
+ .sorting_in_layer = 1,
+ .order_in_layer = 2,
+ }
+ );
EXPECT_EQ(sprite3.data.sorting_in_layer, 1);
EXPECT_EQ(sprite3.data.order_in_layer, 2);
- auto & sprite4
- = entity4.add_component<Sprite>(s4, Sprite::Data{
- .color = Color(0, 0, 0, 0),
- .flip = Sprite::FlipSettings{false, false},
- .sorting_in_layer = 1,
- .order_in_layer = 1,
- });
+ auto & sprite4 = entity4.add_component<Sprite>(
+ s4,
+ Sprite::Data {
+ .color = Color(0, 0, 0, 0),
+ .flip = Sprite::FlipSettings {false, false},
+ .sorting_in_layer = 1,
+ .order_in_layer = 1,
+ }
+ );
EXPECT_EQ(sprite4.data.sorting_in_layer, 1);
EXPECT_EQ(sprite4.data.order_in_layer, 1);
}
@@ -128,8 +136,10 @@ TEST_F(RenderSystemTest, sorting_sprites) {
}
TEST_F(RenderSystemTest, Update) {
- entity1.add_component<Camera>(ivec2{100, 100}, vec2{100, 100},
- Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f});
+ entity1.add_component<Camera>(
+ ivec2 {100, 100}, vec2 {100, 100},
+ Camera::Data {.bg_color = Color::WHITE, .zoom = 1.0f}
+ );
{
vector<reference_wrapper<Sprite>> sprites = this->mgr.get_components_by_type<Sprite>();
ASSERT_EQ(sprites.size(), 4);
@@ -157,8 +167,10 @@ TEST_F(RenderSystemTest, Camera) {
EXPECT_NE(cameras.size(), 1);
}
{
- entity1.add_component<Camera>(ivec2{100, 100}, vec2{100, 100},
- Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f});
+ entity1.add_component<Camera>(
+ ivec2 {100, 100}, vec2 {100, 100},
+ Camera::Data {.bg_color = Color::WHITE, .zoom = 1.0f}
+ );
auto cameras = this->mgr.get_components_by_type<Camera>();
EXPECT_EQ(cameras.size(), 1);
@@ -167,8 +179,10 @@ TEST_F(RenderSystemTest, Camera) {
//TODO improve with newer version
}
TEST_F(RenderSystemTest, Color) {
- entity1.add_component<Camera>(ivec2{100, 100}, vec2{100, 100},
- Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f});
+ entity1.add_component<Camera>(
+ ivec2 {100, 100}, vec2 {100, 100},
+ Camera::Data {.bg_color = Color::WHITE, .zoom = 1.0f}
+ );
auto & sprite = this->mgr.get_components_by_id<Sprite>(entity1.id).front().get();
//ASSERT_NE(sprite.texture.texture.get(), nullptr);
diff --git a/src/test/ReplayManagerTest.cpp b/src/test/ReplayManagerTest.cpp
index 5ee4b40..b2619eb 100644
--- a/src/test/ReplayManagerTest.cpp
+++ b/src/test/ReplayManagerTest.cpp
@@ -14,9 +14,9 @@ class ReplayManagerTest : public Test {
Mediator mediator;
public:
- ComponentManager component_manager{mediator};
- ReplayManager replay_manager{mediator};
- ReplaySystem replay_system{mediator};
+ ComponentManager component_manager {mediator};
+ ReplayManager replay_manager {mediator};
+ ReplaySystem replay_system {mediator};
GameObject entity = component_manager.new_object("foo");
Transform & entity_transform
diff --git a/src/test/ResourceManagerTest.cpp b/src/test/ResourceManagerTest.cpp
index 965eeab..e5a7fad 100644
--- a/src/test/ResourceManagerTest.cpp
+++ b/src/test/ResourceManagerTest.cpp
@@ -16,14 +16,14 @@ class ResourceManagerTest : public Test {
Mediator mediator;
public:
- ResourceManager resource_manager{mediator};
+ ResourceManager resource_manager {mediator};
class Unrelated : public Resource {
using Resource::Resource;
};
- Asset asset_a{"asset/texture/img.png"};
- Asset asset_b{"asset/texture/ERROR.png"};
+ Asset asset_a {"asset/texture/img.png"};
+ Asset asset_b {"asset/texture/ERROR.png"};
class TestResource : public Resource {
public:
diff --git a/src/test/SaveManagerTest.cpp b/src/test/SaveManagerTest.cpp
index 7609e69..fd53200 100644
--- a/src/test/SaveManagerTest.cpp
+++ b/src/test/SaveManagerTest.cpp
@@ -14,12 +14,12 @@ class SaveManagerTest : public Test {
using SaveManager::SaveManager;
// in-memory database for testing
- DB db{};
+ DB db {};
virtual DB & get_db() override { return this->db; }
};
public:
- TestSaveManager mgr{m};
+ TestSaveManager mgr {m};
};
TEST_F(SaveManagerTest, ReadWrite) {
diff --git a/src/test/SceneManagerTest.cpp b/src/test/SceneManagerTest.cpp
index 480e07a..e58ce36 100644
--- a/src/test/SceneManagerTest.cpp
+++ b/src/test/SceneManagerTest.cpp
@@ -15,9 +15,9 @@ using namespace crepe;
class ConcreteScene1 : public Scene {
public:
void load_scene() {
- GameObject object1 = new_object("scene_1", "tag_scene_1", vec2{0, 0}, 0, 1);
- GameObject object2 = new_object("scene_1", "tag_scene_1", vec2{1, 0}, 0, 1);
- GameObject object3 = new_object("scene_1", "tag_scene_1", vec2{2, 0}, 0, 1);
+ GameObject object1 = new_object("scene_1", "tag_scene_1", vec2 {0, 0}, 0, 1);
+ GameObject object2 = new_object("scene_1", "tag_scene_1", vec2 {1, 0}, 0, 1);
+ GameObject object3 = new_object("scene_1", "tag_scene_1", vec2 {2, 0}, 0, 1);
}
string get_name() const { return "scene1"; }
@@ -26,10 +26,10 @@ public:
class ConcreteScene2 : public Scene {
public:
void load_scene() {
- GameObject object1 = new_object("scene_2", "tag_scene_2", vec2{0, 0}, 0, 1);
- GameObject object2 = new_object("scene_2", "tag_scene_2", vec2{0, 1}, 0, 1);
- GameObject object3 = new_object("scene_2", "tag_scene_2", vec2{0, 2}, 0, 1);
- GameObject object4 = new_object("scene_2", "tag_scene_2", vec2{0, 3}, 0, 1);
+ GameObject object1 = new_object("scene_2", "tag_scene_2", vec2 {0, 0}, 0, 1);
+ GameObject object2 = new_object("scene_2", "tag_scene_2", vec2 {0, 1}, 0, 1);
+ GameObject object3 = new_object("scene_2", "tag_scene_2", vec2 {0, 2}, 0, 1);
+ GameObject object4 = new_object("scene_2", "tag_scene_2", vec2 {0, 3}, 0, 1);
}
string get_name() const { return "scene2"; }
@@ -40,7 +40,7 @@ public:
ConcreteScene3(const string & name) : name(name) {}
void load_scene() {
- GameObject object1 = new_object("scene_3", "tag_scene_3", vec2{0, 0}, 0, 1);
+ GameObject object1 = new_object("scene_3", "tag_scene_3", vec2 {0, 0}, 0, 1);
}
string get_name() const { return name; }
@@ -53,8 +53,8 @@ class SceneManagerTest : public ::testing::Test {
Mediator m;
public:
- ComponentManager component_mgr{m};
- SceneManager scene_mgr{m};
+ ComponentManager component_mgr {m};
+ SceneManager scene_mgr {m};
};
TEST_F(SceneManagerTest, loadScene) {
diff --git a/src/test/ScriptSaveManagerTest.cpp b/src/test/ScriptSaveManagerTest.cpp
index 64403c4..e2debae 100644
--- a/src/test/ScriptSaveManagerTest.cpp
+++ b/src/test/ScriptSaveManagerTest.cpp
@@ -19,11 +19,11 @@ public:
using SaveManager::SaveManager;
// in-memory database for testing
- DB db{};
+ DB db {};
virtual DB & get_db() override { return this->db; }
};
- TestSaveManager save_mgr{mediator};
+ TestSaveManager save_mgr {mediator};
};
TEST_F(ScriptSaveManagerTest, GetSaveManager) {
diff --git a/src/test/ScriptSceneTest.cpp b/src/test/ScriptSceneTest.cpp
index 2568049..7d01f14 100644
--- a/src/test/ScriptSceneTest.cpp
+++ b/src/test/ScriptSceneTest.cpp
@@ -13,7 +13,7 @@ using namespace testing;
class ScriptSceneTest : public ScriptTest {
public:
- SceneManager scene_manager{mediator};
+ SceneManager scene_manager {mediator};
class MyScene : public Scene {};
};
diff --git a/src/test/ScriptTest.h b/src/test/ScriptTest.h
index 8637df0..f953aab 100644
--- a/src/test/ScriptTest.h
+++ b/src/test/ScriptTest.h
@@ -17,11 +17,11 @@ protected:
static constexpr const char * OBJ_NAME = "foo";
public:
- crepe::ComponentManager component_manager{mediator};
- crepe::ScriptSystem system{mediator};
- crepe::EventManager event_mgr{mediator};
- crepe::LoopTimerManager loop_timer{mediator};
- crepe::SaveManager save_manager{mediator};
+ crepe::ComponentManager component_manager {mediator};
+ crepe::ScriptSystem system {mediator};
+ crepe::EventManager event_mgr {mediator};
+ crepe::LoopTimerManager loop_timer {mediator};
+ crepe::SaveManager save_manager {mediator};
crepe::GameObject entity = component_manager.new_object(OBJ_NAME);
class MyScript : public crepe::Script {
diff --git a/src/test/ValueBrokerTest.cpp b/src/test/ValueBrokerTest.cpp
index e6bb058..5928c37 100644
--- a/src/test/ValueBrokerTest.cpp
+++ b/src/test/ValueBrokerTest.cpp
@@ -13,7 +13,7 @@ public:
int write_count = 0;
int value = 0;
- ValueBroker<int> broker{
+ ValueBroker<int> broker {
[this](const int & target) -> void {
this->write_count++;
this->value = target;
@@ -23,7 +23,7 @@ public:
return this->value;
},
};
- Proxy<int> proxy{broker};
+ Proxy<int> proxy {broker};
void SetUp() override {
ASSERT_EQ(read_count, 0);