feat(vector): add C2Vector::operator== for C2Vector

This commit is contained in:
fallenoak 2022-12-24 14:29:56 -06:00 committed by GitHub
parent 285073dc24
commit bd159b5369
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 0 deletions

View file

@ -0,0 +1,5 @@
#include "tempest/vector/C2Vector.hpp"
bool C2Vector::operator==(const C2Vector& v) {
return this->x == v.x && this->y == v.y;
}

View file

@ -12,6 +12,7 @@ class C2Vector {
C2Vector(float x, float y)
: x(x)
, y(y) {};
bool operator==(const C2Vector& v);
};
#endif

View file

@ -15,6 +15,22 @@ TEST_CASE("C2Vector", "[vector]") {
}
}
TEST_CASE("C2Vector::operator==", "[vector]") {
SECTION("returns true when compared to identical vector") {
auto vector1 = C2Vector(1.0f, 2.0f);
auto vector2 = C2Vector(1.0f, 2.0f);
auto identical = vector1 == vector2;
REQUIRE(identical);
}
SECTION("returns false when compared to different vector") {
auto vector1 = C2Vector(2.0f, 1.0f);
auto vector2 = C2Vector(1.0f, 2.0f);
auto identical = vector1 == vector2;
REQUIRE(!identical);
}
}
TEST_CASE("C3Vector", "[vector]") {
SECTION("constructs with default constructor") {
C3Vector vector;