From: Francesco Chemolli <5175948+kinkie@users.noreply.github.com> Date: Wed, 22 May 2024 10:59:29 +0000 (+0000) Subject: testRandomUuid: use cppunit exception tests (#1814) X-Git-Tag: SQUID_7_0_1~119 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=61495372ce8e9f578dd9af4b2bba42a2074c7829;p=thirdparty%2Fsquid.git testRandomUuid: use cppunit exception tests (#1814) Do not hand-roll tests for exception-throwing code --- diff --git a/src/tests/testRandomUuid.cc b/src/tests/testRandomUuid.cc index ae7991c4a4..70d1091ef7 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); } }