From 5401b4a6ea1055e27820fd1155c7093d63491214 Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Sun, 6 Aug 2017 18:58:40 +0100 Subject: Removing unnecessary tests and formatting files --- CMakeLists.txt | 6 +++- test/particlebodytest.cpp | 29 ++++++++++++++++++ test/rigidbodytest.cpp | 29 ------------------ test/testbench.cpp | 77 ----------------------------------------------- test/testbench.hpp | 40 ------------------------ 5 files changed, 34 insertions(+), 147 deletions(-) create mode 100644 test/particlebodytest.cpp delete mode 100644 test/rigidbodytest.cpp delete mode 100644 test/testbench.cpp delete mode 100644 test/testbench.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index d9a69a05..b948be9e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,4 +78,8 @@ enable_testing() add_executable(matrixtest ${YAGE_TEST_DIR}/matrixtest.cpp) target_link_libraries(matrixtest gtest_main ${YAGE_LIB_DEP_L}) -add_test(NAME matrixtest COMMAND matrixtest --gtest_repeat=1000 --gtest_break_on_failure) +add_test(NAME MatrixTest COMMAND matrixtest --gtest_repeat=1000 --gtest_break_on_failure) + +add_executable(particlebodytest ${YAGE_TEST_DIR}/particlebodytest.cpp) +target_link_libraries(particlebodytest gtest_main ${YAGE_LIB_DEP_L}) +add_test(NAME ParticleBodyTest COMMAND particlebodytest --gtest_repeat=1000 --gtest_break_on_failure) diff --git a/test/particlebodytest.cpp b/test/particlebodytest.cpp new file mode 100644 index 00000000..54424b37 --- /dev/null +++ b/test/particlebodytest.cpp @@ -0,0 +1,29 @@ +/* ---------------------------------------------------------------------------- + * rigidbodytest.cpp + * + * Copyright (c) 2017 Yann Herklotz Grave -- MIT License + * See file LICENSE for more details + * ---------------------------------------------------------------------------- + */ + +#include "Physics/particlebody.hpp" + +#include + +int main(int, char**) { + yage::ParticleBody body; + for (int i = 0; i < 60 * 3; ++i) { + body.update(); + std::cout << "position: " << body.xPosition() << ", " + << body.yPosition() << "\n"; + } + + double ideal_position = 0.5 * -9.81 * 3 * 3; + + std::cout << "Ideal Position: " << ideal_position << "\n"; + + if (body.yPosition() < ideal_position * 0.95 && + body.yPosition() > ideal_position * 1.05) + return 0; + return 1; +} diff --git a/test/rigidbodytest.cpp b/test/rigidbodytest.cpp deleted file mode 100644 index f3ad61f3..00000000 --- a/test/rigidbodytest.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* ---------------------------------------------------------------------------- - * rigidbodytest.cpp - * - * Copyright (c) 2017 Yann Herklotz Grave -- MIT License - * See file LICENSE for more details - * ---------------------------------------------------------------------------- - */ - -#include "Physics/particlebody.hpp" - -#include - -int main(int, char**) -{ - yage::ParticleBody body; - for(int i=0; i<60*3; ++i) - { - body.update(); - std::cout<<"position: "<ideal_position*1.05) - return 0; - return 1; -} diff --git a/test/testbench.cpp b/test/testbench.cpp deleted file mode 100644 index eb09a82d..00000000 --- a/test/testbench.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* ---------------------------------------------------------------------------- - * testbench.cpp - * - * Copyright (c) 2017 Yann Herklotz Grave -- MIT License - * See file LICENSE for more details - * ---------------------------------------------------------------------------- - */ - -#include "testbench.hpp" - -#include -#include - -void TestBench::startTest(const std::string &test_name) -{ - incrementer++; - - Test test(test_name, false); - - tests_.push_back(test); -} - -void TestBench::endTest(bool pass) -{ - incrementer--; - - if(incrementer!=0) - throw std::runtime_error("Start and End don't match"); - - if(pass) - passed++; - else - failed++; - - tests_[passed+failed-1].passed=pass; -} - -void TestBench::printResults() -{ - std::sort(tests_.begin(), tests_.end(), [] (const Test &a, const Test &b) { - if(a.name -- MIT License - * See file LICENSE for more details - * ---------------------------------------------------------------------------- - */ - -#ifndef TEST_BENCH_HPP -#define TEST_BENCH_HPP - -#include -#include - -struct Test -{ - std::string name; - bool passed; - - Test(const std::string &_name, bool _passed) : name(_name), passed(_passed) {} -}; - -class TestBench -{ -private: - int incrementer=0; - int passed=0; - int failed=0; - - std::vector tests_; - -public: - TestBench() : tests_() {} - - void startTest(const std::string &test_name); - void endTest(bool pass); - void printResults(); -}; - -#endif -- cgit