diff --git a/test/caosdb_test_utility.h.in b/test/caosdb_test_utility.h.in index baac638f5668a05c6464fef99410bb345ba8b3c3..b53ea62178f38fa65d8fda4ef30af5b9cc1d31d0 100644 --- a/test/caosdb_test_utility.h.in +++ b/test/caosdb_test_utility.h.in @@ -29,20 +29,38 @@ * @author Timm Fitschen * @date 2021-07-07 */ -#define EXPECT_THROW_MESSAGE(statement, exeption_type, message) \ +#define EXPECT_THROW_MESSAGE(statement, exception_type, message) \ EXPECT_THROW( \ - try { statement; } catch (const exeption_type &e) { \ + try { statement; } catch (const exception_type &e) { \ EXPECT_EQ(std::string(e.what()), message); \ throw; \ }, \ - exeption_type) -#define ASSERT_THROW_MESSAGE(statement, exeption_type, message) \ + exception_type) +#define ASSERT_THROW_MESSAGE(statement, exception_type, message) \ ASSERT_THROW( \ - try { statement; } catch (const exeption_type &e) { \ + try { statement; } catch (const exception_type &e) { \ ASSERT_EQ(std::string(e.what()), message); \ throw; \ }, \ - exeption_type) + exception_type) +#define EXPECT_THROW_STARTS_WITH(statement, exception_type, pattern) \ + EXPECT_THROW( \ + try { statement; } catch (const exception_type &e) { \ + auto pat_s = std::string(pattern); \ + EXPECT_EQ(std::string(e.what()).substr(0, pat_s.size()), \ + pat_s); \ + throw; \ + }, \ + exception_type) +#define ASSERT_THROW_STARTS_WITH(statement, exception_type, message) \ + ASSERT_THROW( \ + try { statement; } catch (const exception_type &e) { \ + auto pat_s = std::string(pattern); \ + ASSERT_EQ(std::string(e.what()).substr(0, pat_s.size()), \ + pat_s); \ + throw; \ + }, \ + exception_type) #define EXPECT_NULL(statement) \ if (statement != nullptr) { \ FAIL() << "Should be a nullptr"; \