From 51ccc49265bd26341e89403724bdd4894dfcce70 Mon Sep 17 00:00:00 2001 From: fallenoak Date: Thu, 26 Nov 2020 12:46:16 -0600 Subject: [PATCH] feat(vector): add C2Vector constructors --- tempest/vector/C2Vector.hpp | 6 ++++++ test/Vector.cpp | 14 ++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/tempest/vector/C2Vector.hpp b/tempest/vector/C2Vector.hpp index 708d4fe..47a85f4 100644 --- a/tempest/vector/C2Vector.hpp +++ b/tempest/vector/C2Vector.hpp @@ -6,6 +6,12 @@ class C2Vector { // Member variables float x = 0.0f; float y = 0.0f; + + // Member functions + C2Vector() = default; + C2Vector(float x, float y) + : x(x) + , y(y) {}; }; #endif diff --git a/test/Vector.cpp b/test/Vector.cpp index 54f6bca..2a2267c 100644 --- a/test/Vector.cpp +++ b/test/Vector.cpp @@ -1,6 +1,20 @@ #include "tempest/Vector.hpp" #include "test/Test.hpp" +TEST_CASE("C2Vector", "[vector]") { + SECTION("constructs with default constructor") { + C2Vector vector; + REQUIRE(vector.x == 0.0f); + REQUIRE(vector.y == 0.0f); + } + + SECTION("constructs with xy constructor") { + auto vector = C2Vector(1.0f, 2.0f); + REQUIRE(vector.x == 1.0f); + REQUIRE(vector.y == 2.0f); + } +} + TEST_CASE("C3Vector", "[vector]") { SECTION("constructs with default constructor") { C3Vector vector;