Skip to content

Commit

Permalink
test will skip renderer stuff if the renderer is NULL (#13)
Browse files Browse the repository at this point in the history
* test will skip renderer stuff if the renderer is NULL

* actually called getRenderer lol
  • Loading branch information
oddbookworm authored Jan 24, 2024
1 parent 05c9bc3 commit 3f4c702
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 27 deletions.
46 changes: 23 additions & 23 deletions test/test_Math.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ TEST_F(MathTest, Vec2DefaultConstructor)
{
Vec2 vec;

ASSERT_EQ(vec.x, 0.0);
EXPECT_EQ(vec.x, 0.0);
EXPECT_EQ(vec.y, 0.0);
}

TEST_F(MathTest, Vec2TwoArgConstructor)
{
Vec2 vec = Vec2(1.0, 2.0);

ASSERT_EQ(vec.x, 1.0);
EXPECT_EQ(vec.x, 1.0);
EXPECT_EQ(vec.y, 2.0);
}

Expand All @@ -40,9 +40,9 @@ TEST_F(MathTest, EqualityOperator)
Vec2 third = Vec2(2.0, 1.0);
Vec2 fourth = Vec2(1.0, 3.0);

ASSERT_EQ(first, second);
ASSERT_NE(first, third);
ASSERT_NE(second, fourth);
EXPECT_EQ(first, second);
EXPECT_NE(first, third);
EXPECT_NE(second, fourth);
EXPECT_NE(third, fourth);
}

Expand All @@ -55,7 +55,7 @@ TEST_F(MathTest, Vec2ThreeArgConstructor)
// but that should make these appear equal when using first's
// operator==. Second's operator== uses the default tolerance
// of 0.0001, which means that they should appear not equal
ASSERT_EQ(first, second);
EXPECT_EQ(first, second);
EXPECT_NE(second, first);
}

Expand All @@ -65,8 +65,8 @@ TEST_F(MathTest, AdditionOperator)
Vec2 second = Vec2(-1.0, 2.0);
Vec2 third = Vec2(900.6, 322.5);

ASSERT_EQ(first + second, Vec2(0.0, 4.0));
ASSERT_EQ(Vec2() + third, third);
EXPECT_EQ(first + second, Vec2(0.0, 4.0));
EXPECT_EQ(Vec2() + third, third);
EXPECT_EQ(second + third, Vec2(899.6, 324.5));
}

Expand All @@ -76,9 +76,9 @@ TEST_F(MathTest, MultiplyOperator)
Vec2 second = Vec2(2.0, 4.0);
Vec2 third = Vec2(-1.0, -2.0);

ASSERT_EQ(2 * first, first * 2.0);
ASSERT_EQ(2.0f * first, second);
ASSERT_EQ(first * -1, third);
EXPECT_EQ(2 * first, first * 2.0);
EXPECT_EQ(2.0f * first, second);
EXPECT_EQ(first * -1, third);
EXPECT_EQ(second * 0.5, Vec2() - third);
}

Expand All @@ -89,9 +89,9 @@ TEST_F(MathTest, CopyConstructor)
Vec2 original = Vec2(1.0, 2.0);
Vec2 copy = original;

ASSERT_EQ(original, copy);
ASSERT_NE(&original, &copy);
ASSERT_NE(&(original.x), &(copy.x));
EXPECT_EQ(original, copy);
EXPECT_NE(&original, &copy);
EXPECT_NE(&(original.x), &(copy.x));
EXPECT_NE(&(original.y), &(copy.y));
}

Expand All @@ -102,9 +102,9 @@ TEST_F(MathTest, GetLength)
Vec2 third = Vec2(INFINITY, INFINITY);
Vec2 fourth = Vec2(4.0, 3.0);

ASSERT_EQ(first.getLength(), 0.0);
ASSERT_EQ(second.getLength(), 5.0);
ASSERT_EQ(second.getLength(), fourth.getLength());
EXPECT_EQ(first.getLength(), 0.0);
EXPECT_EQ(second.getLength(), 5.0);
EXPECT_EQ(second.getLength(), fourth.getLength());
EXPECT_EQ(third.getLength(), -1.0);
}

Expand All @@ -114,12 +114,12 @@ TEST_F(MathTest, Normalize)
Vec2 second = Vec2(3.0, 4.0);
Vec2 third = Vec2(INFINITY, INFINITY);

ASSERT_EQ(first.normalize(), false);
ASSERT_EQ(first, Vec2::ZERO());
ASSERT_EQ(second.normalize(), true);
ASSERT_EQ(second, Vec2(0.6, 0.8));
ASSERT_EQ(third.normalize(), false);
ASSERT_EQ(third.x, std::numeric_limits<double>::infinity());
EXPECT_EQ(first.normalize(), false);
EXPECT_EQ(first, Vec2::ZERO());
EXPECT_EQ(second.normalize(), true);
EXPECT_EQ(second, Vec2(0.6, 0.8));
EXPECT_EQ(third.normalize(), false);
EXPECT_EQ(third.x, std::numeric_limits<double>::infinity());
EXPECT_EQ(third.y, std::numeric_limits<double>::infinity());
}

Expand Down
11 changes: 7 additions & 4 deletions test/test_Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace
class WindowTest : public ::testing::Test
{
protected:
WindowTest() : m_size(320, 240), m_scale(2) {}
WindowTest() : m_size(320, 240), m_scale(2) { kn::ErrorLogger::setConsoleOnly(); }

virtual ~WindowTest() {}

Expand All @@ -26,9 +26,12 @@ class WindowTest : public ::testing::Test

TEST_F(WindowTest, WindowInit)
{
EXPECT_EQ(kn::window::getSize().x, m_size.x);
EXPECT_EQ(kn::window::getSize().y, m_size.y);
EXPECT_EQ(kn::window::getScale(), m_scale);
if (kn::window::getRenderer() != NULL)
{
EXPECT_EQ(kn::window::getSize().x, m_size.x);
EXPECT_EQ(kn::window::getSize().y, m_size.y);
EXPECT_EQ(kn::window::getScale(), m_scale);
}
EXPECT_EQ(kn::window::getTitle(), std::string("Kraken Window"));
}

Expand Down

0 comments on commit 3f4c702

Please sign in to comment.