diff options
author | Yann Herklotz <ymherklotz@gmail.com> | 2017-08-05 11:06:06 +0100 |
---|---|---|
committer | Yann Herklotz <ymherklotz@gmail.com> | 2017-08-06 17:07:43 +0100 |
commit | 23ed1151eda8d939fcdd85dceb39773b12ac17f3 (patch) | |
tree | 255f4382e08368b8fffd92fe43c22b31aeee82fb /test/matrixtest.cpp | |
parent | 30461c89fd53e14bb9f5a83eaf6d72040931b62a (diff) | |
download | YAGE-23ed1151eda8d939fcdd85dceb39773b12ac17f3.tar.gz YAGE-23ed1151eda8d939fcdd85dceb39773b12ac17f3.zip |
Adding googletest for test bench
Diffstat (limited to 'test/matrixtest.cpp')
-rw-r--r-- | test/matrixtest.cpp | 60 |
1 files changed, 26 insertions, 34 deletions
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(); } |