aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2017-06-23 21:19:11 +0100
committerYann Herklotz <ymherklotz@gmail.com>2017-06-23 21:19:11 +0100
commit205f2459063a123cabd83fb66b3880a72fb357bf (patch)
tree7daabd15f3470ed5ffe37eebfd0c6f5e6baaa308 /test
parent3e8751d8cee8e41031655e9f4d5f364f6100b503 (diff)
downloadYAGE-205f2459063a123cabd83fb66b3880a72fb357bf.tar.gz
YAGE-205f2459063a123cabd83fb66b3880a72fb357bf.zip
Continuing tests
Diffstat (limited to 'test')
-rw-r--r--test/matrixtest.cpp66
1 files changed, 58 insertions, 8 deletions
diff --git a/test/matrixtest.cpp b/test/matrixtest.cpp
index fd9a0bb7..ce4e9187 100644
--- a/test/matrixtest.cpp
+++ b/test/matrixtest.cpp
@@ -14,6 +14,10 @@ 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()
@@ -21,27 +25,73 @@ bool matrixAssign()
yage::Matrix<4, 5, int> m;
m[2][3]=5;
- return m[2][3]==5;
+ return m[2][3]==4;
}
bool matrixAddition()
{
yage::Matrix<4, 4, int> m1, m2;
- m1[1][1] = 293;
- m2[1][1] = 583;
+ m1[1][1]=293;
+ m2[1][1]=583;
- yage::Matrix<4, 4, int> m3 = m1 + m2;
+ yage::Matrix<4, 4, int> m3=m1+m2;
- return m3[1][1] == 876;
+ return m3[1][1]==876;
+}
+
+bool vectorDotProduct()
+{
+ yage::Vector<3, int> v1, v2;
+ v1[0] = 2;
+ v1[1] = 3;
+ v1[2] = 5;
+ v2[0] = 9;
+ v2[1] = 6;
+ v2[2] = 8;
+
+ int x = yage::matrix::dot(v1, v2);
+
+ return x==76;
+}
+
+bool matrixMultiplication()
+{
+
}
int main()
{
TestBench tb;
- test(tb, "Matrix Assign", matrixAssign());
- test(tb, "Matrix Addition", matrixAddition());
+ bool all_passed=true;
+
+ try
+ {
+ test(tb, "Matrix Assign", matrixAssign());
+ }
+ catch(std::exception e)
+ {
+ std::cout<<e.what()<<'\n';
+ }
+
+ try
+ {
+ test(tb, "Matrix Addition", matrixAddition());
+ }
+ catch(std::exception e)
+ {
+ std::cout<<e.what()<<'\n';
+ }
+
+ try
+ {
+ test(tb, "Vector Dot Product", vectorDotProduct());
+ }
+ catch(std::string e)
+ {
+ std::cout<<e<<'\n';
+ }
tb.printResults();
- return 0;
+ return all_passed;
}