mirror of
https://github.com/allankoechke/soci.git
synced 2026-11-30 10:58:24 +00:00
Use CHECK_THAT() in PostgreSQL unit tests
This is simpler than manually using strncmp() or string::find(). Omit one negative test, it's not clear what was it actually testing for.
This commit is contained in:
@@ -431,9 +431,7 @@ TEST_CASE("PostgreSQL literals", "[postgresql][into]")
|
||||
}
|
||||
catch (soci_error const & e)
|
||||
{
|
||||
char const * expectedPrefix = "Cannot convert data";
|
||||
CAPTURE(e.what());
|
||||
CHECK(strncmp(e.what(), expectedPrefix, strlen(expectedPrefix)) == 0);
|
||||
CHECK_THAT( e.what(), Catch::StartsWith("Cannot convert data") );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -696,12 +694,7 @@ TEST_CASE("PostgreSQL statement prepare failure", "[postgresql][prepare]")
|
||||
}
|
||||
catch(soci_error const& e)
|
||||
{
|
||||
std::string const msg(e.what());
|
||||
CAPTURE(msg);
|
||||
|
||||
// poor-man heuristics
|
||||
CHECK(msg.find("prepared statement") == std::string::npos);
|
||||
CHECK(msg.find("operator does not exist") != std::string::npos);
|
||||
CHECK_THAT( e.what(), Catch::Contains("operator does not exist") );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user