diff options
author | Yann Herklotz <ymherklotz@gmail.com> | 2017-06-23 14:50:23 +0100 |
---|---|---|
committer | Yann Herklotz <ymherklotz@gmail.com> | 2017-06-23 14:50:23 +0100 |
commit | 3e8751d8cee8e41031655e9f4d5f364f6100b503 (patch) | |
tree | 4102a22d5a40f584c3a734229a310791a65ae5be | |
parent | 884c915340b86e162df9bdff9f67ae25407cbaab (diff) | |
download | YAGE-3e8751d8cee8e41031655e9f4d5f364f6100b503.tar.gz YAGE-3e8751d8cee8e41031655e9f4d5f364f6100b503.zip |
Testing matrix
-rw-r--r-- | test/matrixtest.cpp | 32 | ||||
-rw-r--r-- | test/testbench.cpp | 14 |
2 files changed, 35 insertions, 11 deletions
diff --git a/test/matrixtest.cpp b/test/matrixtest.cpp index 4150641f..fd9a0bb7 100644 --- a/test/matrixtest.cpp +++ b/test/matrixtest.cpp @@ -10,14 +10,38 @@ #include "testbench.hpp" +void test(TestBench &tb, const std::string &test_name, bool result) +{ + tb.startTest(test_name); + tb.endTest(result); +} + +bool matrixAssign() +{ + yage::Matrix<4, 5, int> m; + m[2][3]=5; + + return m[2][3]==5; +} + +bool matrixAddition() +{ + yage::Matrix<4, 4, int> m1, m2; + m1[1][1] = 293; + m2[1][1] = 583; + + yage::Matrix<4, 4, int> m3 = m1 + m2; + + return m3[1][1] == 876; +} + int main() { TestBench tb; - tb.startTest("Hello"); - tb.endTest(true); - tb.startTest("Bye"); - tb.endTest(true); + test(tb, "Matrix Assign", matrixAssign()); + test(tb, "Matrix Addition", matrixAddition()); + tb.printResults(); return 0; } diff --git a/test/testbench.cpp b/test/testbench.cpp index 54ce047e..77bd4a5a 100644 --- a/test/testbench.cpp +++ b/test/testbench.cpp @@ -42,9 +42,9 @@ void TestBench::printResults() }); printf("Results:\n"); - printf("+------------+---------+\n"); - printf("| Test Name | Result |\n"); - printf("+------------+---------+\n"); + printf("+---------------------------+---------+\n"); + printf("| Test Name | Result |\n"); + printf("+---------------------------+---------+\n"); for(auto test : tests_) { std::string result; @@ -53,9 +53,9 @@ void TestBench::printResults() else result="FAIL"; - char test_name[10]; + char test_name[25]; - for(std::size_t i=0; i<10; ++i) + for(std::size_t i=0; i<25; ++i) { if(i<test.name.size()) test_name[i]=test.name[i]; @@ -63,9 +63,9 @@ void TestBench::printResults() test_name[i]=' '; } - printf("| %10.10s | %6s |\n", test_name, result.c_str()); + printf("| %25.25s | %6s |\n", test_name, result.c_str()); } - printf("+------------+---------+\n"); + printf("+---------------------------+---------+\n"); printf("\nSummary:\n"); printf("+--------+--------+\n"); printf("| Passed | %6d |\n", passed); |