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

Function SECTION

tests/unit/debug.cpp:67–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65TEST_CASE( "setMaxNumReportedSigFigs", TEST_CATEGORY ) {
66
67 SECTION( LABEL_CORRECTNESS ) {
68
69 qcomp scalar = getQcomp(0.12345, 0.12345);
70
71 vector<std::string> refs = {
72 "0.1+0.1i",
73 "0.12+0.12i",
74 "0.123+0.123i",
75 "0.1235+0.1235i", // rounded
76 "0.12345+0.12345i"
77 };
78
79 // disable auto \n after lines
80 setNumReportedNewlines(0);
81
82 for (size_t numSigFigs=1; numSigFigs<=refs.size(); numSigFigs++) {
83
84 setMaxNumReportedSigFigs(numSigFigs);
85
86 // redirect stdout to buffer
87 std::stringstream buffer;
88 std::streambuf * old = std::cout.rdbuf(buffer.rdbuf());
89 reportScalar("", scalar);
90 std::cout.rdbuf(old);
91 std::string out = buffer.str();
92
93 std::string ref = refs[numSigFigs-1];
94
95 CAPTURE( numSigFigs, ref );
96 REQUIRE( out == ref );
97 }
98 }
99
100 SECTION( LABEL_VALIDATION ) {
101

Callers 1

DYNAMIC_SECTIONFunction · 0.70

Calls 15

getQcompFunction · 0.85
setNumReportedNewlinesFunction · 0.85
setMaxNumReportedSigFigsFunction · 0.85
reportScalarFunction · 0.85
reportStrFunction · 0.85
reportQuESTEnvFunction · 0.85
getCachedDensmatrsFunction · 0.85
setSeedsFunction · 0.85
getNumSeedsFunction · 0.85
getSeedsFunction · 0.85
setValidationOnFunction · 0.85
setValidationOffFunction · 0.85

Tested by

no test coverage detected