ngnrsaa / qflex

Flexible Quantum Circuit Simulator (qFlex) implements an efficient tensor network, CPU-based simulator of large quantum circuits.
Apache License 2.0
97 stars 24 forks source link

Try-catch blocks in tests #205

Closed alankao64 closed 4 years ago

alankao64 commented 4 years ago

In the long term, we should change these to try-catch blocks with explicit failure expectations, e.g.:

// test case
try {
  should_fail();
  FAIL() << "Expected should_fail to fail, but it didn't.";
} catch (string msg) {
  EXPECT_THAT(msg, HasSubstr("expected message"));
}

That way we can ensure that the test is actually hitting the expected failure, and not some other exception.

Originally posted by @95-martin-orion in https://github.com/ngnrsaa/qflex/pull/110#issuecomment-543478708