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
+15 -2
View File
@@ -1,4 +1,5 @@
#include <gtest/gtest.h>
#include "TestHelpers/AssertThrowEx.hpp"
#include <cstdint>
#include <array>
#include <vector>
@@ -366,7 +367,13 @@ TEST(DesCryptTests, ShortKeyTest)
{
{
std::array<uint8_t, DesCrypt::KeySize - 1> key = {};
ASSERT_THROW(DesCrypt::Key(key.begin(), key.end()), Chaos::Service::ChaosException);
ASSERT_THROW_EX(DesCrypt::Key(key.begin(), key.end()),
Chaos::Service::ChaosException,
{
ASSERT_EQ("DesCrypt::Key: invalid key length "
"(8 bytes required)",
ex.GetMessage());
});
}
}
@@ -374,7 +381,13 @@ TEST(DesCryptTests, LongKeyTest)
{
{
std::array<uint8_t, DesCrypt::KeySize + 1> key = {};
ASSERT_THROW(DesCrypt::Key(key.begin(), key.end()), Chaos::Service::ChaosException);
ASSERT_THROW_EX(DesCrypt::Key(key.begin(), key.end()),
Chaos::Service::ChaosException,
{
ASSERT_EQ("DesCrypt::Key: invalid key length "
"(8 bytes required)",
ex.GetMessage());
});
}
}