]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
testRandomUuid: use cppunit exception tests (#1814)
authorFrancesco Chemolli <5175948+kinkie@users.noreply.github.com>
Wed, 22 May 2024 10:59:29 +0000 (10:59 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Wed, 22 May 2024 13:19:23 +0000 (13:19 +0000)
Do not hand-roll tests for exception-throwing code

src/tests/testRandomUuid.cc

index ae7991c4a4b2105826665f610ba62574027d3596..70d1091ef727d36dcd7ec569fc72df5a2ea69f8d 100644 (file)
@@ -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);
     }
 }