]> 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)
committerAmos Jeffries <yadij@users.noreply.github.com>
Thu, 23 May 2024 15:45:26 +0000 (03:45 +1200)
Do not hand-roll tests for exception-throwing code

src/tests/testRandomUuid.cc

index a9ec87335e4dfb5f629090d4f70a0bcfc22ec105..08581ef2b9681bc865ddf8f941f1ec367c08b85c 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);
     }
 }