MCPcopy Create free account
hub / github.com/QuEST-Kit/QuEST / SECTION

Function SECTION

tests/unit/matrices.cpp:53–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51TEST_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

Callers 1

matrices.cppFile · 0.70

Calls 15

getRandomMatrixFunction · 0.85
REQUIRE_AGREEFunction · 0.85
getRandomDiagonalMatrixFunction · 0.85
getDiagonalsFunction · 0.85
getDiagonalMatrixFunction · 0.85
getNumCachedQubitsFunction · 0.85
createCompMatrFunction · 0.85
getPow2Function · 0.85
getQuESTEnvFunction · 0.85
destroyCompMatrFunction · 0.85
createDiagMatrFunction · 0.85
destroyDiagMatrFunction · 0.85

Tested by

no test coverage detected