summaryrefslogtreecommitdiffstats
path: root/src/math/test/geometry_test.cpp
diff options
context:
space:
mode:
authorPiotr Dziwinski <piotrdz@gmail.com>2012-09-11 21:14:32 +0200
committerPiotr Dziwinski <piotrdz@gmail.com>2012-09-11 21:14:32 +0200
commit6c21dceb35f7aaf90e54d3c030130e9465f343f3 (patch)
tree17a873a9b9729c619f183ceeeb5ae9106180ec26 /src/math/test/geometry_test.cpp
parentefe4f0baddf10124581e4fcb88d55a52838b06a1 (diff)
downloadcolobot-6c21dceb35f7aaf90e54d3c030130e9465f343f3.tar.gz
colobot-6c21dceb35f7aaf90e54d3c030130e9465f343f3.tar.bz2
colobot-6c21dceb35f7aaf90e54d3c030130e9465f343f3.zip
Tests rewrite and Doxygen in src/math
- rewritten tests to use new framework - updated/reformatted Doxygen - removed legacy conversions
Diffstat (limited to 'src/math/test/geometry_test.cpp')
-rw-r--r--src/math/test/geometry_test.cpp84
1 files changed, 21 insertions, 63 deletions
diff --git a/src/math/test/geometry_test.cpp b/src/math/test/geometry_test.cpp
index 07fa2cf..8b83b8d 100644
--- a/src/math/test/geometry_test.cpp
+++ b/src/math/test/geometry_test.cpp
@@ -20,53 +20,41 @@
#include "../func.h"
#include "../geometry.h"
-#include "../conv.h"
-#include "../../old/math3d.h"
-#include "../../old/d3dutil.h"
-#include <d3d.h>
-#include <cstdio>
+#include "gtest/gtest.h"
-using namespace std;
const float TEST_TOLERANCE = 1e-5;
// Test for rewritten function RotateAngle()
-int TestRotateAngle()
+TEST(GeometryTest, RotateAngleTest)
{
- if (! Math::IsEqual(Math::RotateAngle(0.0f, 0.0f), 0.0f, TEST_TOLERANCE))
- return __LINE__;
+ EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(0.0f, 0.0f), 0.0f, TEST_TOLERANCE));
- if (! Math::IsEqual(Math::RotateAngle(1.0f, 0.0f), 0.0f, TEST_TOLERANCE))
- return __LINE__;
+ EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(1.0f, 0.0f), 0.0f, TEST_TOLERANCE));
- if (! Math::IsEqual(Math::RotateAngle(1.0f, 1.0f), 0.25f * Math::PI, TEST_TOLERANCE))
- return __LINE__;
+ EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(1.0f, 1.0f), 0.25f * Math::PI, TEST_TOLERANCE));
- if (! Math::IsEqual(Math::RotateAngle(0.0f, 2.0f), 0.5f * Math::PI, TEST_TOLERANCE))
- return __LINE__;
+ EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(0.0f, 2.0f), 0.5f * Math::PI, TEST_TOLERANCE));
- if (! Math::IsEqual(Math::RotateAngle(-0.5f, 0.5f), 0.75f * Math::PI, TEST_TOLERANCE))
- return __LINE__;
+ EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(-0.5f, 0.5f), 0.75f * Math::PI, TEST_TOLERANCE));
- if (! Math::IsEqual(Math::RotateAngle(-1.0f, 0.0f), Math::PI, TEST_TOLERANCE))
- return __LINE__;
+ EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(-1.0f, 0.0f), Math::PI, TEST_TOLERANCE));
- if (! Math::IsEqual(Math::RotateAngle(-1.0f, -1.0f), 1.25f * Math::PI, TEST_TOLERANCE))
- return __LINE__;
+ EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(-1.0f, -1.0f), 1.25f * Math::PI, TEST_TOLERANCE));
- if (! Math::IsEqual(Math::RotateAngle(0.0f, -2.0f), 1.5f * Math::PI, TEST_TOLERANCE))
- return __LINE__;
+ EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(0.0f, -2.0f), 1.5f * Math::PI, TEST_TOLERANCE));
- if (! Math::IsEqual(Math::RotateAngle(1.0f, -1.0f), 1.75f * Math::PI, TEST_TOLERANCE))
- return __LINE__;
-
- return 0;
+ EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(1.0f, -1.0f), 1.75f * Math::PI, TEST_TOLERANCE));
}
// Tests for other altered, complex or uncertain functions
+/*
+
+ TODO: write meaningful tests with proper test values
+
int TestAngle()
{
const Math::Vector u(-0.0786076246943884, 0.2231249091714256, -1.1601361718477805);
@@ -360,42 +348,12 @@ int TestTransform()
return 0;
}
-int main()
-{
- // Functions to test
- int (*TESTS[])() =
- {
- TestRotateAngle,
- TestAngle,
- TestRotateView,
- TestLookatPoint,
- TestProjection,
- TestLoadViewMatrix,
- TestLoadProjectionMatrix,
- TestLoadTranslationMatrix,
- TestLoadScaleMatrix,
- TestLoadRotationXMatrix,
- TestLoadRotationYMatrix,
- TestLoadRotationZMatrix,
- TestLoadRotationMatrix,
- TestLoadRotationXZYMatrix,
- TestLoadRotationZXYMatrix,
- TestTransform
- };
- const int TESTS_SIZE = sizeof(TESTS) / sizeof(*TESTS);
-
- int result = 0;
- for (int i = 0; i < TESTS_SIZE; ++i)
- {
- result = TESTS[i]();
- if (result != 0)
- {
- fprintf(stderr, "Test function %d failed at line %d\n", i+1, result);
- return result;
- }
- }
+*/
- fprintf(stderr, "All tests successful\n");
- return 0;
+int main(int argc, char* argv[])
+{
+ ::testing::InitGoogleTest(&argc, argv);
+
+ return RUN_ALL_TESTS();
}