diff --git a/test/test_random_kernel.cpp b/test/test_random_kernel.cpp new file mode 100644 index 0000000..2511b39 --- /dev/null +++ b/test/test_random_kernel.cpp @@ -0,0 +1,43 @@ +#include "Solver.h" +#include +#include +#include +#include +#include + +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> 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; +}