From 7d1f2891e14b1e2ac754d1836f74e1713964efa0 Mon Sep 17 00:00:00 2001 From: Francesco Chemolli <5175948+kinkie@users.noreply.github.com> Date: Wed, 22 May 2024 10:59:29 +0000 Subject: [PATCH] testRandomUuid: use cppunit exception tests (#1814) Do not hand-roll tests for exception-throwing code --- src/tests/testRandomUuid.cc | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/tests/testRandomUuid.cc b/src/tests/testRandomUuid.cc index a9ec87335e..08581ef2b9 100644 --- a/src/tests/testRandomUuid.cc +++ b/src/tests/testRandomUuid.cc @@ -78,15 +78,7 @@ void TestRandomUuid::testInvalidIds() { for (const auto &id: InvalidIds) { - try { - RandomUuid uuid(id.second); - std::cerr << std::endl - << "FAIL: " << id.first - << Debug::Extra << "error: should be rejected" << std::endl; - } catch (const TextException &e) { - continue; // success, caught a malformed UUID - } - CPPUNIT_FAIL("failed to reject an invalid UUID"); + CPPUNIT_ASSERT_THROW(RandomUuid uuid(id.second), TextException); } } -- 2.47.2