add simple test for matrix

This commit is contained in:
chatlanin 2022-03-30 12:49:59 +03:00
parent 2a57555436
commit 393aa844a4
4 changed files with 54 additions and 0 deletions

View File

@ -23,6 +23,16 @@ int f(int a)
return ++a; return ++a;
} }
int plus(int a)
{
return a++;
}
int minus(int a)
{
return a--;
}
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
{// ex: string::split_str {// ex: string::split_str
@ -155,4 +165,9 @@ int main(int argc, char *argv[])
hack::log()(full_name); hack::log()(full_name);
hack::log()(hack::string::str_concat + "super", + "string"); hack::log()(hack::string::str_concat + "super", + "string");
} }
{// ex: utils::func_concat
auto combine ( hack::utils::func_concat(plus, minus) );
hack::log("")("func_concat result: ", combine(3));
}
} }

View File

@ -24,4 +24,23 @@ namespace hack::utils
return cached->second; return cached->second;
}; };
} }
template<typename T, typename... Args>
auto func_concat(T t, Args... args)
{
if constexpr (sizeof...(args) > 0)
{
return [=](auto... params)
{
return t(func_concat(args...)(params...));
};
}
else
{
return [=](auto... params)
{
return t(params...);
};
}
}
} }

11
tests/math.cpp Normal file
View File

@ -0,0 +1,11 @@
#include <gtest/gtest.h>
#include "math/matrix.hpp"
TEST(matrix, check)
{
hack::matrix<int, 2> m { { 0, 0, 1 }, { 0, 1, 1 } };
m[1][1] = 123;
ASSERT_EQ(m.size(), 3);
}

View File

@ -27,3 +27,12 @@ test(
dependencies: [ deps, gtest_dep ] dependencies: [ deps, gtest_dep ]
) )
) )
test(
'math',
executable(
'math',
'math.cpp',
dependencies: [ deps, gtest_dep ]
)
)