aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.dir-locals.el9
-rw-r--r--.gitmodules4
-rw-r--r--CMakeLists.txt35
-rw-r--r--README.md4
m---------googletest0
-rw-r--r--test/matrixtest.cpp60
6 files changed, 58 insertions, 54 deletions
diff --git a/.dir-locals.el b/.dir-locals.el
index 4afe10c5..7f49a89d 100644
--- a/.dir-locals.el
+++ b/.dir-locals.el
@@ -2,15 +2,18 @@
"-I../../include/YAGE/"
"-I../../../include/YAGE/"
"-I/usr/include/"
- "-I/usr/include/SDL2/"))
+ "-I/usr/include/SDL2/"
+ "-I../googletest/googletest/include/"))
(company-c-headers-path-user . ("../include/YAGE/"
"../../include/YAGE/"
"../../../include/YAGE/"
"/usr/include/"
- "/usr/include/SDL2/"))
+ "/usr/include/SDL2/"
+ "../googletest/googletest/include/"))
(flycheck-clang-include-path . ("../include/YAGE/"
"../../include/YAGE/"
"../../../include/YAGE/"
"/usr/include/"
- "/usr/include/SDL2/")))))
+ "/usr/include/SDL2/"
+ "../googletest/googletest/include")))))
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 00000000..e07c3b23
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,4 @@
+[submodule "googletest"]
+ path = googletest
+ url = https://github.com/google/googletest.git
+ branch = master
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 23efffdb..77de0782 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -42,6 +42,21 @@ set(YAGE_SOURCES
${PROJECT_SOURCE_DIR}/src/texturecache.cpp
${PROJECT_SOURCE_DIR}/src/window.cpp)
+# Initializing google test
+# prevents overriding the parent project's compiler/linter settings on windows
+set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
+
+# Add googletest directly to our build. This defines
+# the gtest and gtest_main targets.
+add_subdirectory(${PROJECT_SOURCE_DIR}/googletest)
+
+# The gtest/gtest_main targets carry header search path
+# dependencies automatically when using CMake 2.8.11 or
+# later. Otherwise we have to add them here ourselves.
+if (CMAKE_VERSION VERSION_LESS 2.8.11)
+ include_directories("${gtest_SOURCE_DIR}/include")
+endif()
+
# find libraries
find_package(OpenGL REQUIRED)
find_package(GLEW REQUIRED)
@@ -54,23 +69,13 @@ include_directories(${YAGE_INCLUDE_DIR}
# make it a static library
add_library(${PROJECT_NAME} ${YAGE_SOURCES})
-# add tests
-add_executable(rigidbodytest
- ${YAGE_TEST_DIR}/rigidbodytest.cpp)
-target_link_libraries(rigidbodytest
- ${YAGE_LIBRARIES}
- ${OPENGL_LIBRARIES}
- ${GLEW_LIBRARIES})
-
-add_executable(matrixtest
- ${YAGE_TEST_DIR}/matrixtest.cpp
- ${YAGE_TEST_DIR}/testbench.cpp)
-target_link_libraries(matrixtest
- ${YAGE_LIBRARIES}
+set(YAGE_LIB_DEP_L yage
${OPENGL_LIBRARIES}
${GLEW_LIBRARIES})
# enable tests
enable_testing()
-add_test(RigidBodyTest ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/rigidbodytest)
-add_test(MatrixTest ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/matrixtest)
+
+add_executable(matrixtest ${YAGE_TEST_DIR}/matrixtest.cpp)
+target_link_libraries(matrixtest gtest_main ${YAGE_LIB_DEP_L})
+add_test(NAME matrixtest COMMAND matrixtest)
diff --git a/README.md b/README.md
index 52432bbc..d31829a2 100644
--- a/README.md
+++ b/README.md
@@ -6,5 +6,5 @@ YAGE stands for Yet Another Game Engine.
License
-------
-Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com> -- MIT License,
-see file LICENSE for more details.
+Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com> -- MIT License,
+see file [LICENSE](/LICENSE) for more details.
diff --git a/googletest b/googletest
new file mode 160000
+Subproject ca102b1f9d1f4c8a8c6f7a87b3e80d0af4b8789
diff --git a/test/matrixtest.cpp b/test/matrixtest.cpp
index c84118df..aecf4c87 100644
--- a/test/matrixtest.cpp
+++ b/test/matrixtest.cpp
@@ -8,37 +8,25 @@
#include "Math/math.hpp"
-#include "testbench.hpp"
+#include "gtest/gtest.h"
-void test(TestBench &tb, const std::string &test_name, bool result)
-{
- tb.startTest(test_name);
- tb.endTest(result);
- if(!result)
- {
- throw std::runtime_error(test_name+" failed...");
- }
-}
-
-bool matrixAssign()
+int matrixAssign(int number)
{
yage::Matrix<4, 5, int> m;
- m[2][3]=5;
+ m[2][3]=number;
- return m[2][3]==5;
+ return m[2][3];
}
-bool matrixAddition()
+int matrixAddition(int num1, int num2)
{
yage::Matrix<4, 4, int> m1, m2;
- m1[1][1]=293;
- m2[1][1]=583;
+ m1[1][1]=num1;
+ m2[1][1]=num2;
yage::Matrix<4, 4, int> m3=m1+m2;
- std::cout<<m3<<'\n';
-
- return m3[1][1]==876;
+ return m3[1][1];
}
bool vectorDotProduct()
@@ -58,24 +46,28 @@ bool vectorDotProduct()
bool matrixMultiplication()
{
-
+ return false;
}
-int main()
-{
- TestBench tb;
+// TESTS
- bool all_passed=true;
+TEST(Matrix, Assign)
+{
+ ASSERT_EQ(29348, matrixAssign(29348));
+}
- try{ test(tb, "Matrix Assign", matrixAssign()); }
- catch(std::exception e) { std::cout<<e.what()<<'\n'; }
+TEST(Matrix, Addition)
+{
+ ASSERT_EQ(5793+2389, matrixAddition(5793, 2389));
+}
- try{ test(tb, "Matrix Addition", matrixAddition()); }
- catch(std::exception e) { std::cout<<e.what()<<'\n'; }
+TEST(Matrix, DotProduct)
+{
+ ASSERT_TRUE(vectorDotProduct());
+}
- try{ test(tb, "Vector Dot Product", vectorDotProduct()); }
- catch(std::string e) { std::cout<<e<<'\n'; }
-
- tb.printResults();
- return all_passed;
+int main(int argc, char **argv)
+{
+ testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
}