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_6_10~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7d1f2891e14b1e2ac754d1836f74e1713964efa0;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 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); } }