From a62992c7dd3f0da3e572ff459486a72f3c852a5b Mon Sep 17 00:00:00 2001 From: lucaspalomodevelop Date: Tue, 3 Oct 2023 17:45:59 +0200 Subject: [PATCH] add testing exceptions --- src/testing/testing.hpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/testing/testing.hpp b/src/testing/testing.hpp index cf2e18d..50fe43c 100644 --- a/src/testing/testing.hpp +++ b/src/testing/testing.hpp @@ -178,5 +178,21 @@ namespace lpstd testSuite(); } + void testThrow(std::function testCase) + { + try + { + testCase(); + } + catch (std::exception &e) + { + std::cout << "✅ Expected exception thrown: " << e.what() << std::endl; + Results.passed++; + return; + } + std::cout << "❌ Expected exception not thrown" << std::endl; + Results.failed++; + } + } }