aboutsummaryrefslogtreecommitdiffstats
path: root/tests/matrixtest.cpp
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2017-09-20 00:29:45 +0100
committerYann Herklotz <ymherklotz@gmail.com>2017-09-20 00:29:45 +0100
commit39ca43ca3b24dcae76e1283ec8af4a16c845e2b7 (patch)
treed3aa095fa982695ffc3e621f62797a041ac36cb3 /tests/matrixtest.cpp
parent34396f0483d94229e3a315e5eeb90c77c1425273 (diff)
downloadYAGE-39ca43ca3b24dcae76e1283ec8af4a16c845e2b7.tar.gz
YAGE-39ca43ca3b24dcae76e1283ec8af4a16c845e2b7.zip
More tests and adding spritesheet support
Diffstat (limited to 'tests/matrixtest.cpp')
-rw-r--r--tests/matrixtest.cpp49
1 files changed, 17 insertions, 32 deletions
diff --git a/tests/matrixtest.cpp b/tests/matrixtest.cpp
index 9cc8bccc..58786bae 100644
--- a/tests/matrixtest.cpp
+++ b/tests/matrixtest.cpp
@@ -6,51 +6,27 @@
* ----------------------------------------------------------------------------
*/
-#include <yage/yage.h>
#include <gtest/gtest.h>
+#include <yage/yage.h>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <vector>
-template <int Size>
-int matrixAddition(int num1, int num2)
-{
- yage::Matrix<Size, Size, int> m1, m2;
- m1[1][1] = num1;
- m2[1][1] = num2;
-
- yage::Matrix<Size, Size, int> m3 = m1 + m2;
-
- return m3[1][1];
-}
-
-int vectorDotProduct(const std::vector<int> &vec_contents_f,
- const std::vector<int> &vec_contents_s)
-{
- yage::Vector<3, int> v1(vec_contents_f);
- yage::Vector<3, int> v2(vec_contents_s);
-
- int x = yage::matrix::dot(v1, v2);
-
- return x;
-}
-
-bool matrixMultiplication()
-{
- return false;
-}
-
// TESTS
TEST(Matrix, Assign)
{
double rand_num = rand();
yage::Matrix<5, 5, double> mat1;
+
mat1[3][2] = rand_num;
+
ASSERT_EQ(rand_num, mat1[3][2]);
- yage::Matrix<2, 2, double> mat2 {{rand_num, rand_num, rand_num, rand_num}};
+
+ yage::Matrix<2, 2, double> mat2{{rand_num, rand_num, rand_num, rand_num}};
+
ASSERT_EQ(rand_num, mat2[1][0]);
}
@@ -58,18 +34,27 @@ TEST(Matrix, Addition)
{
int rand_x = rand();
int rand_y = rand();
- ASSERT_EQ(rand_x + rand_y, matrixAddition<10>(rand_x, rand_y));
+ yage::Matrix<5, 5, int> m1, m2;
+
+ m1[2][4] = rand_x;
+ m2[2][4] = rand_y;
+
+ ASSERT_EQ(rand_x + rand_y, (m1 + m2)[2][4]);
}
TEST(Vector, DotProduct)
{
std::vector<int> contents_i = {rand() % 100, rand() % 100, rand() % 100};
std::vector<int> contents_j = {rand() % 100, rand() % 100, rand() % 100};
+ yage::Vector<3, int> v1{contents_i};
+ yage::Vector<3, int> v2{contents_j};
+
int sum = 0;
for (std::size_t i = 0; i < contents_i.size(); ++i) {
sum += contents_i[i] * contents_j[i];
}
- ASSERT_EQ(sum, vectorDotProduct(contents_i, contents_j));
+
+ ASSERT_EQ(sum, yage::matrix::dot(v1, v2));
}
int main(int argc, char **argv)