| 51 | TEST_CASE( "getCompMatr1", TEST_CATEGORY ) { |
| 52 | |
| 53 | SECTION( LABEL_CORRECTNESS ) { |
| 54 | |
| 55 | constexpr int dim = 2; |
| 56 | qmatrix ref = getRandomMatrix(dim); |
| 57 | |
| 58 | SECTION( LABEL_C_INTERFACE ) { |
| 59 | |
| 60 | // 2D compile-time array |
| 61 | qcomp arr[dim][dim] = {{ref[0][0], ref[0][1]}, {ref[1][0], ref[1][1]}}; |
| 62 | REQUIRE_AGREE( getCompMatr1(arr), ref ); |
| 63 | |
| 64 | // nested pointers |
| 65 | qcomp** ptrs = (qcomp**) malloc(dim * sizeof *ptrs); |
| 66 | for (int i=0; i<dim; i++) { |
| 67 | ptrs[i] = (qcomp*) malloc(dim * sizeof **ptrs); |
| 68 | for (int j=0; j<dim; j++) |
| 69 | ptrs[i][j] = ref[i][j]; |
| 70 | } |
| 71 | REQUIRE_AGREE( getCompMatr1(ptrs), ref ); |
| 72 | |
| 73 | // array of pointers |
| 74 | qcomp* ptrArr[dim]; |
| 75 | for (int i=0; i<dim; i++) |
| 76 | ptrArr[i] = ptrs[i]; |
| 77 | REQUIRE_AGREE( getCompMatr1(ptrArr), ref ); |
| 78 | |
| 79 | // cleanup |
| 80 | for (int i=0; i<dim; i++) |
| 81 | free(ptrs[i]); |
| 82 | free(ptrs); |
| 83 | } |
| 84 | |
| 85 | SECTION( LABEL_CPP_INTERFACE ) { |
| 86 | |
| 87 | // nested vectors |
| 88 | REQUIRE_AGREE( getCompMatr1(ref), ref ); |
| 89 | |
| 90 | // inline vectors |
| 91 | REQUIRE_AGREE( getCompMatr1({{ref[0][0],ref[0][1]},{ref[1][0],ref[1][1]}}), ref ); |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | SECTION( LABEL_VALIDATION ) { |
| 96 |
no test coverage detected