From 2a121b57c481eafb6f7f699ebc74ec56f96f0e37 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 22 Apr 2025 16:07:11 +0200 Subject: [PATCH] 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. --- tests/sqlite3/test-sqlite3.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/sqlite3/test-sqlite3.cpp b/tests/sqlite3/test-sqlite3.cpp index ab0df575..ac64a4c6 100644 --- a/tests/sqlite3/test-sqlite3.cpp +++ b/tests/sqlite3/test-sqlite3.cpp @@ -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\".")); + } } }