This commit is contained in:
@@ -1,6 +1,25 @@
|
||||
#include "Vect.h"
|
||||
#include "test_assert.h"
|
||||
|
||||
const static int EXECUTION_COUNT = 100000;
|
||||
static constexpr int MATRIX_MAX_SIZE = 7;
|
||||
|
||||
static int GetRandomSize() {
|
||||
return rand() % MATRIX_MAX_SIZE + 1;
|
||||
}
|
||||
|
||||
static int GetRandomInt() {
|
||||
return GetRandomSize();
|
||||
}
|
||||
|
||||
static Matrix GetRandomMatrix(std::size_t a_Raw, std::size_t a_Column) {
|
||||
Matrix matrix {a_Raw, a_Column};
|
||||
|
||||
std::generate(matrix.GetLineIterator(0), matrix.GetLineIterator(a_Raw), []() { return GetRandomInt(); });
|
||||
|
||||
return matrix;
|
||||
}
|
||||
|
||||
void TestVect() {
|
||||
Vect vect1 {{3, 2, {
|
||||
1, 2,
|
||||
@@ -41,8 +60,22 @@ void TestVectAffine() {
|
||||
test_assert(!aff.IsElementOf(Matrix::ColumnVector({1, 2, 3})));
|
||||
}
|
||||
|
||||
void TestLinearSystem() {
|
||||
for (std::size_t i = 0; i < EXECUTION_COUNT; i++) {
|
||||
Vect vect = GetRandomMatrix(GetRandomSize(), GetRandomSize());
|
||||
|
||||
Matrix systeme = vect.GetLinearSystem();
|
||||
|
||||
for (std::size_t j = 0; j < vect.GetCardinal(); j++) {
|
||||
Matrix nullMatrix {systeme.GetColumnCount(), 1};
|
||||
test_assert(systeme * vect.GetVector(j) == nullMatrix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
TestVect();
|
||||
TestVectAffine();
|
||||
TestLinearSystem();
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user