added random kernel tests
All checks were successful
Linux arm64 / Build (push) Successful in 1m1s

This commit is contained in:
2024-03-06 22:53:07 +01:00
parent 1b994daf3c
commit 13c9bc40db

View File

@@ -0,0 +1,43 @@
#include "Solver.h"
#include <cassert>
#include <cstdlib>
#include <future>
#include <iostream>
#include <vector>
static constexpr int EXECUTION_COUNT = 100;
static constexpr int MATRIX_MAX_SIZE = 100;
static const Solver solver;
static unsigned int GetRandomInt() {
return rand() % MATRIX_MAX_SIZE + 1;
}
static void Test() {
Matrix matrix {GetRandomInt(), GetRandomInt()};
for (std::size_t i = 0; i < matrix.GetRawCount(); i++) {
for (std::size_t j = 0; j < matrix.GetColumnCount(); j++) {
matrix.at(i, j) = GetRandomInt();
}
}
Vect vect1 = solver.Kernel(matrix);
Vect vect2 = solver.Kernel(vect1.GetLinearSystem());
assert(vect1 == vect2);
}
int main() {
srand(time(0));
std::vector<std::future<void>> results;
for (int i = 0; i < EXECUTION_COUNT; i++) {
auto handle = std::async(std::launch::async, &Test);
results.push_back(std::move(handle));
}
return EXIT_SUCCESS;
}