Skip to content

Commit

Permalink
added more Vec2 tests should be 100% coverage now
Browse files Browse the repository at this point in the history
  • Loading branch information
jmacey committed Sep 27, 2023
1 parent 2ca0071 commit 6d4191a
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ sonar.coverage.exclusions = ./tests/files/* ./src/ngl/* ./src/shaders/*

sonar.c.file.suffixes=-
sonar.cpp.file.suffixes=.cc,.cpp,.cxx,.c++,.hh,.hpp,.hxx,.h++,.ipp,.c,.h
sonar.cfamily.reportingCppStandardOverride=c++17
sonar.cfamily.reportingCppStandardOverride=c++17
46 changes: 45 additions & 1 deletion tests/Vec2Tests.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <gtest/gtest.h>
#include <ngl/Types.h>
#include <ngl/Vec2.h>
#include <ngl/Mat3.h>
#include <ngl/Mat2.h>
#include <string>
#include <sstream>
#include <vector>
Expand Down Expand Up @@ -199,6 +199,14 @@ TEST(Vec2,multiplyFloat)
EXPECT_FLOAT_EQ(c.m_y,4.0f);
}

TEST(Vec2,multVec)
{
ngl::Vec2 a(1.0f,2.0f);
a=a*a;
EXPECT_FLOAT_EQ(a.m_x,1.0f);
EXPECT_FLOAT_EQ(a.m_y,4.0f);
}


TEST(Vec2,multiplyFloatEqual)
{
Expand Down Expand Up @@ -242,3 +250,39 @@ TEST(Vec2,divideEqualVec)
EXPECT_FLOAT_EQ(a.m_x,0.5f);
EXPECT_FLOAT_EQ(a.m_y,1.0f);
}

TEST(Vec2,negate)
{
ngl::Vec2 a(1.0f,2.0f);
a=-a;
EXPECT_FLOAT_EQ(a.m_x,-1.0f);
EXPECT_FLOAT_EQ(a.m_y,-2.0f);
}

TEST(Vec2,setWithVec)
{
ngl::Vec2 a(1.0f,2.0f);
auto b=ngl::Vec2();
b.set(a);
EXPECT_FLOAT_EQ(b.m_x,1.0f);
EXPECT_FLOAT_EQ(b.m_y,2.0f);
}

TEST(Vec2,notEqual)
{
ngl::Vec2 a(1.0f,2.0f);
ngl::Vec2 b(2.0f,2.0f);
ASSERT_TRUE(a!=b);
ASSERT_FALSE(a!=a);
}


TEST(Vec2,multMat2)
{
ngl::Mat2 m(1,2,3,4);
ngl::Vec2 a(1.0f,2.0f);
auto res=a*m;
EXPECT_FLOAT_EQ(res.m_x,7.0f);
EXPECT_FLOAT_EQ(res.m_y,10.0f);

}

0 comments on commit 6d4191a

Please sign in to comment.