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:
Vadim Zeitlin
2025-04-22 16:07:11 +02:00
parent 51a5715164
commit 2a121b57c4

View File

@@ -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\"."));
}
}
}