mirror of
https://github.com/SOCI/soci.git
synced 2026-02-13 17:18:35 -06:00
Rewrite SQLite unit test to use explicit try/catch
Don't use CHECK_THROWS_WITH(), it's convenient but not very flexible, while an explicit try/catch will allow us to add more checks on the exception object in the upcoming commits.
This commit is contained in:
@@ -147,10 +147,18 @@ TEST_CASE("SQLite foreign keys", "[sqlite][foreignkeys]")
|
||||
{
|
||||
sql << "pragma foreign_keys = on";
|
||||
|
||||
CHECK_THROWS_WITH(sql << "delete from parent where id = 1",
|
||||
Catch::Contains(
|
||||
try
|
||||
{
|
||||
sql << "delete from parent where id = 1";
|
||||
|
||||
FAIL("Expected exception not thrown");
|
||||
}
|
||||
catch (soci_error const& e)
|
||||
{
|
||||
CHECK_THAT(e.what(), Catch::Contains(
|
||||
"FOREIGN KEY constraint failed while executing "
|
||||
"\"delete from parent where id = 1\"."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user