Skip to content

Commit

Permalink
unit tests also test for compatibility with fixed size C arrays (in a…
Browse files Browse the repository at this point in the history
…ddition to several other array types)
  • Loading branch information
jewettaij committed Jan 31, 2020
1 parent cc5ba16 commit a2eacf4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ matrix:
#- now test again using array<array<double,5>,5>
- g++ -g -O0 -DUSE_ARRAY_OF_ARRAY -I../include -o test_jacobi test.cpp
- valgrind --leak-check=yes --error-exitcode=1 ./test_jacobi 5 10 1e-09 1e+09
#- now test again using double (*)[5]
- g++ -g -O0 -DUSE_C_FIXED_SIZE_ARRAYS -I../include -o test_jacobi test.cpp
- valgrind --leak-check=yes --error-exitcode=1 ./test_jacobi 5 10 1e-09 1e+09
- cd ../

- language: cpp
Expand Down Expand Up @@ -72,5 +75,8 @@ matrix:
#- now test again using array<array<double,5>,5>
- clang++ -g -O0 -DUSE_ARRAY_OF_ARRAY -I../include -o test_jacobi test.cpp
- valgrind --leak-check=yes --error-exitcode=1 ./test_jacobi 5 10 1e-09 1e+09
#- now test again using double (*)[5]
- clang++ -g -O0 -DUSE_C_FIXED_SIZE_ARRAYS -I../include -o test_jacobi test.cpp
- valgrind --leak-check=yes --error-exitcode=1 ./test_jacobi 5 10 1e-09 1e+09
- cd ../

10 changes: 5 additions & 5 deletions tests/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ void GenRandSymm(Matrix M, //<! store the matrix here
#elif defined USE_ARRAY_OF_ARRAYS
mmult<array<array<Scalar,NF>,NF>&, array<array<Scalar,NF>,NF>&>
#elif defined USE_C_FIXED_SIZE_ARRAYS
mmult<Scalar *[NF], Scalar *[NF]>
mmult<Scalar (*)[NF], Scalar (*)[NF]>
#else
mmult<Scalar**, Scalar const *const *>
#endif
Expand All @@ -287,7 +287,7 @@ void GenRandSymm(Matrix M, //<! store the matrix here
#elif defined USE_ARRAY_OF_ARRAYS
mmult<array<array<Scalar,NF>,NF>&, array<array<Scalar,NF>,NF>&>
#elif defined USE_C_FIXED_SIZE_ARRAYS
mmult<Scalar *[NF], Scalar *[NF]>
mmult<Scalar (*)[NF], Scalar (*)[NF]>
#else
mmult<Scalar**, Scalar const *const *>
#endif
Expand Down Expand Up @@ -368,7 +368,7 @@ void TestJacobi(int n, //<! matrix size
n = NF;
cout << "Testing C fixed size arrays.\n"
"(Ignoring first argument, and setting matrix size to " << n << ")" << endl;
Jacobi<Scalar, Scalar*, Scalar *[NF], Scalar *[NF]> ecalc(n);
Jacobi<Scalar, Scalar*, Scalar (*)[NF], Scalar (*)[NF]> ecalc(n);
// allocate the matrix, eigenvalues, eigenvectors
Scalar M[NF][NF];
Scalar evects[NF][NF];
Expand Down Expand Up @@ -420,7 +420,7 @@ void TestJacobi(int n, //<! matrix size
#elif defined USE_ARRAY_OF_ARRAYS
GenRandSymm<Scalar, array<Scalar,NF>&, array<array<Scalar,NF>,NF>&>
#elif defined USE_C_FIXED_SIZE_ARRAYS
GenRandSymm<Scalar, Scalar*, Scalar *[NF]>
GenRandSymm<Scalar, Scalar*, Scalar (*)[NF]>
#else
GenRandSymm<Scalar, Scalar*, Scalar**>
#endif
Expand All @@ -442,7 +442,7 @@ void TestJacobi(int n, //<! matrix size
#elif defined USE_ARRAY_OF_ARRAYS
SortRows<Scalar, array<Scalar,NF>&, array<array<Scalar,NF>,NF>&>
#elif defined USE_C_FIXED_SIZE_ARRAYS
SortRows<Scalar, Scalar*, Scalar *[NF]>
SortRows<Scalar, Scalar*, Scalar (*)[NF]>
#else
SortRows<Scalar, Scalar*, Scalar**>
#endif
Expand Down

0 comments on commit a2eacf4

Please sign in to comment.