improve tests
This commit is contained in:
46
test/test_jordan.cpp
Normal file
46
test/test_jordan.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
#include "Matrix.h"
|
||||
#include <cassert>
|
||||
|
||||
#ifdef NDEBUG
|
||||
#error "Il faut être en debug mode ! xmake f -m debug"
|
||||
#endif
|
||||
|
||||
struct Test{
|
||||
Matrix mat;
|
||||
Matrix res;
|
||||
};
|
||||
|
||||
static const std::vector<Test> TEST_MATRICES = {
|
||||
// test 1
|
||||
{{3, 3, {
|
||||
1, 2, 3,
|
||||
4, 5, 6,
|
||||
7, 8, 9,
|
||||
}}, {3, 3, {
|
||||
1, 0, -1,
|
||||
0, 1, 2,
|
||||
0, 0, 0,
|
||||
}}},
|
||||
// test 2
|
||||
{{3, 3, {
|
||||
4, 5, 6,
|
||||
1, 2, 3,
|
||||
7, 8, 9,
|
||||
}}, {3, 3, {
|
||||
1, 0, -1,
|
||||
0, 1, 2,
|
||||
0, 0, 0,
|
||||
}}}
|
||||
};
|
||||
|
||||
void test() {
|
||||
for (Test test : TEST_MATRICES) {
|
||||
test.mat.GaussJordan(true);
|
||||
assert(test.mat == test.res);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
test();
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user