Improve negative assertions by checking the actual exceptions' content.

This commit is contained in:
hashlag
2026-08-02 03:06:27 +03:00
parent 8b9b67aa0c
commit c03b392bcc
8 changed files with 247 additions and 46 deletions
+12 -2
View File
@@ -1,4 +1,5 @@
#include <gtest/gtest.h>
#include "TestHelpers/AssertThrowEx.hpp"
#include <cstring>
#include <string>
#include <cstdint>
@@ -108,7 +109,16 @@ TEST(HmacTests, UninitializedHmacTest)
{
Hmac<Md5Hasher> hmac;
ASSERT_THROW(hmac.Update(in.begin(), in.end()), Chaos::Service::ChaosException);
ASSERT_THROW(hmac.Finish(), Chaos::Service::ChaosException);
ASSERT_THROW_EX(hmac.Update(in.begin(), in.end()),
Chaos::Service::ChaosException,
{
ASSERT_EQ("Hmac: not initialized", ex.GetMessage());
});
ASSERT_THROW_EX(hmac.Finish(),
Chaos::Service::ChaosException,
{
ASSERT_EQ("Hmac: not initialized", ex.GetMessage());
});
}
}