aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authormax-001 <maxsmits21@kpnmail.nl>2024-11-22 14:35:04 +0100
committermax-001 <maxsmits21@kpnmail.nl>2024-11-22 14:35:04 +0100
commita11b647bec22890be44d68d15de6b73f8955722d (patch)
treebbdd12e1a2ec6fe423f036c98b2cd13ab5f3c319 /src/test
parent3965297b579351745c0f5c87aa12829f707c98fd (diff)
Replaced Vector2<double> by vec2 typedef
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ECSTest.cpp36
-rw-r--r--src/test/ParticleTest.cpp10
-rw-r--r--src/test/PhysicsTest.cpp4
-rw-r--r--src/test/SceneManagerTest.cpp14
4 files changed, 32 insertions, 32 deletions
diff --git a/src/test/ECSTest.cpp b/src/test/ECSTest.cpp
index 98d3a27..b552581 100644
--- a/src/test/ECSTest.cpp
+++ b/src/test/ECSTest.cpp
@@ -17,7 +17,7 @@ public:
};
TEST_F(ECSTest, createGameObject) {
- GameObject obj = mgr.new_object("body", "person", Vector2<double>{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>();
@@ -37,8 +37,8 @@ TEST_F(ECSTest, createGameObject) {
}
TEST_F(ECSTest, deleteAllGameObjects) {
- GameObject obj0 = mgr.new_object("body", "person", Vector2<double>{0, 0}, 0, 1);
- GameObject obj1 = mgr.new_object("body", "person", Vector2<double>{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();
@@ -48,7 +48,7 @@ TEST_F(ECSTest, deleteAllGameObjects) {
EXPECT_EQ(metadata.size(), 0);
EXPECT_EQ(transform.size(), 0);
- GameObject obj2 = mgr.new_object("body2", "person2", Vector2<double>{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>();
@@ -70,8 +70,8 @@ TEST_F(ECSTest, deleteAllGameObjects) {
}
TEST_F(ECSTest, deleteGameObject) {
- GameObject obj0 = mgr.new_object("body", "person", Vector2<double>{0, 0}, 0, 1);
- GameObject obj1 = mgr.new_object("body", "person", Vector2<double>{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);
@@ -96,7 +96,7 @@ TEST_F(ECSTest, deleteGameObject) {
TEST_F(ECSTest, manyGameObjects) {
for (int i = 0; i < 5000; i++) {
- GameObject obj = mgr.new_object("body", "person", Vector2<double>{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>();
@@ -128,7 +128,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, Vector2<double>{0, 0}, i, 0);
+ GameObject obj = mgr.new_object("body", tag, vec2{0, 0}, i, 0);
}
metadata = mgr.get_components_by_type<Metadata>();
@@ -139,8 +139,8 @@ TEST_F(ECSTest, manyGameObjects) {
}
TEST_F(ECSTest, getComponentsByID) {
- GameObject obj0 = mgr.new_object("body", "person", Vector2<double>{0, 0}, 0, 1);
- GameObject obj1 = mgr.new_object("body", "person", Vector2<double>{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);
@@ -163,15 +163,15 @@ TEST_F(ECSTest, getComponentsByID) {
TEST_F(ECSTest, tooMuchComponents) {
try {
- GameObject obj0 = mgr.new_object("body", "person", Vector2<double>{0, 0}, 0, 1);
- obj0.add_component<Transform>(Vector2<double>{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"));
}
try {
- GameObject obj1 = mgr.new_object("body", "person", Vector2<double>{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(),
@@ -187,14 +187,14 @@ TEST_F(ECSTest, tooMuchComponents) {
TEST_F(ECSTest, partentChild) {
{
- GameObject body = mgr.new_object("body", "person", Vector2<double>{0, 0}, 0, 1);
+ GameObject body = mgr.new_object("body", "person", vec2{0, 0}, 0, 1);
GameObject right_leg
- = mgr.new_object("rightLeg", "person", Vector2<double>{1, 1}, 0, 1);
- GameObject left_leg = mgr.new_object("leftLeg", "person", Vector2<double>{1, 1}, 0, 1);
+ = 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", Vector2<double>{2, 2}, 0, 1);
+ = mgr.new_object("rightFoot", "person", vec2{2, 2}, 0, 1);
GameObject left_foot
- = mgr.new_object("leftFoot", "person", Vector2<double>{2, 2}, 0, 1);
+ = mgr.new_object("leftFoot", "person", vec2{2, 2}, 0, 1);
// Set the parent of each GameObject
right_foot.set_parent(right_leg);
diff --git a/src/test/ParticleTest.cpp b/src/test/ParticleTest.cpp
index 48e6630..8b81e74 100644
--- a/src/test/ParticleTest.cpp
+++ b/src/test/ParticleTest.cpp
@@ -25,7 +25,7 @@ public:
std::vector<std::reference_wrapper<Transform>> transforms
= mgr.get_components_by_id<Transform>(0);
if (transforms.empty()) {
- GameObject game_object = mgr.new_object("", "", Vector2<double>{0, 0}, 0, 0);
+ GameObject game_object = mgr.new_object("", "", vec2{0, 0}, 0, 0);
Color color(0, 0, 0, 0);
Sprite & test_sprite = game_object.add_component<Sprite>(
@@ -42,11 +42,11 @@ public:
.max_angle = 0,
.begin_lifespan = 0,
.end_lifespan = 0,
- .force_over_time = Vector2<double>{0, 0},
+ .force_over_time = vec2{0, 0},
.boundary{
.width = 0,
.height = 0,
- .offset = Vector2<double>{0, 0},
+ .offset = vec2{0, 0},
.reset_on_exit = false,
},
.sprite = test_sprite,
@@ -68,8 +68,8 @@ public:
emitter.data.max_angle = 0;
emitter.data.begin_lifespan = 0;
emitter.data.end_lifespan = 0;
- emitter.data.force_over_time = Vector2<double>{0, 0};
- emitter.data.boundary = {0, 0, Vector2<double>{0, 0}, false};
+ emitter.data.force_over_time = vec2{0, 0};
+ emitter.data.boundary = {0, 0, vec2{0, 0}, false};
for (auto & particle : emitter.data.particles) {
particle.active = false;
}
diff --git a/src/test/PhysicsTest.cpp b/src/test/PhysicsTest.cpp
index 4fd9b14..33b6020 100644
--- a/src/test/PhysicsTest.cpp
+++ b/src/test/PhysicsTest.cpp
@@ -20,12 +20,12 @@ public:
vector<reference_wrapper<Transform>> transforms
= mgr.get_components_by_id<Transform>(0);
if (transforms.empty()) {
- auto entity = mgr.new_object("", "", Vector2<double>{0, 0}, 0, 0);
+ 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,
- .max_linear_velocity = Vector2<double>{10, 10},
+ .max_linear_velocity = vec2{10, 10},
.max_angular_velocity = 10,
.constraints = {0, 0},
.use_gravity = true,
diff --git a/src/test/SceneManagerTest.cpp b/src/test/SceneManagerTest.cpp
index f4cf4fd..676da58 100644
--- a/src/test/SceneManagerTest.cpp
+++ b/src/test/SceneManagerTest.cpp
@@ -17,11 +17,11 @@ public:
void load_scene() {
auto & mgr = this->component_manager;
GameObject object1
- = mgr.new_object("scene_1", "tag_scene_1", Vector2<double>{0, 0}, 0, 1);
+ = mgr.new_object("scene_1", "tag_scene_1", vec2{0, 0}, 0, 1);
GameObject object2
- = mgr.new_object("scene_1", "tag_scene_1", Vector2<double>{1, 0}, 0, 1);
+ = mgr.new_object("scene_1", "tag_scene_1", vec2{1, 0}, 0, 1);
GameObject object3
- = mgr.new_object("scene_1", "tag_scene_1", Vector2<double>{2, 0}, 0, 1);
+ = mgr.new_object("scene_1", "tag_scene_1", vec2{2, 0}, 0, 1);
}
string get_name() const { return "scene1"; }
@@ -34,13 +34,13 @@ public:
void load_scene() {
auto & mgr = this->component_manager;
GameObject object1
- = mgr.new_object("scene_2", "tag_scene_2", Vector2<double>{0, 0}, 0, 1);
+ = mgr.new_object("scene_2", "tag_scene_2", vec2{0, 0}, 0, 1);
GameObject object2
- = mgr.new_object("scene_2", "tag_scene_2", Vector2<double>{0, 1}, 0, 1);
+ = mgr.new_object("scene_2", "tag_scene_2", vec2{0, 1}, 0, 1);
GameObject object3
- = mgr.new_object("scene_2", "tag_scene_2", Vector2<double>{0, 2}, 0, 1);
+ = mgr.new_object("scene_2", "tag_scene_2", vec2{0, 2}, 0, 1);
GameObject object4
- = mgr.new_object("scene_2", "tag_scene_2", Vector2<double>{0, 3}, 0, 1);
+ = mgr.new_object("scene_2", "tag_scene_2", vec2{0, 3}, 0, 1);
}
string get_name() const { return "scene2"; }