I am currently working in my matrix class. After completion of the matrix I am planing to write a unit test for this matrix class testing all the functions that I wrote.
class Matrix{
Matrix(size_t, size_t);
Matrix transpose();
Matrix operator+(const Matrix&)const;
...
private:
std::vector<std::vector<double>> matrix;
};
How am I planning to test?
Well currently I am planning not use any external library and use my own testing method.
void test_transpose(){
matrix a = {...some value..}; // nxm
// I calculate the expected value via matlab
matrix expected = {...some value..}; // mxn
matrix b = a.transpose();
assert(expected == b);
}
void test_xxxxx1(){
....
}
int main(){
test_transpose();
test_xxxxx1();
test_xxxxx2();
...
return 0;
}
Can anyone give me advice if the method I am following is correct or is there any better method that I should follow?