1

I'm using Catch to write unit tests and came across a problem where my test fails because an exception is thrown, even though I use REQUIRE_THROWS_AS. This is my test:

SECTION("Get column index for inexistent name") {
    REQUIRE_THROWS_AS(result->column_index("inexistent"), std::out_of_range);
}

And this is the exception I get on my console:

$ tests/unit_tests "Test Result"
libc++abi.dylib: terminating with uncaught exception of type std::out_of_range: Name not found.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
unit_tests is a Catch v1.5.8 host application.
Run with -? for options

-------------------------------------------------------------------------------
Test Result
  Query empty table
  Get column index for inexistent name
-------------------------------------------------------------------------------
<path to file>:22
...............................................................................

<path to file>:46: FAILED:
due to a fatal error condition:
  SIGABRT - Abort (abnormal termination) signal

===============================================================================
test cases: 1 | 1 failed
assertions: 8 | 7 passed | 1 failed

If I understand Catch this exception is exactly what I'm trying to catch right?

4

1 回答 1

0

make clean解决了这个问题。

于 2017-01-16T13:24:03.293 回答