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 <vector>
#include <array>
#include <cstdint>
@@ -62,8 +63,17 @@ TEST(Arc4CryptTests, UninitializedArc4CryptTest)
std::array<uint8_t, 10> in = {};
std::array<uint8_t, 10> out = {};
ASSERT_THROW(arc4.Encrypt(out.begin(), in.begin(), in.size()), Chaos::Service::ChaosException);
ASSERT_THROW(arc4.Decrypt(out.begin(), in.begin(), in.size()), Chaos::Service::ChaosException);
ASSERT_THROW_EX(arc4.Encrypt(out.begin(), in.begin(), in.size()),
Chaos::Service::ChaosException,
{
ASSERT_EQ("Arc4Crypt: not initialized", ex.GetMessage());
});
ASSERT_THROW_EX(arc4.Decrypt(out.begin(), in.begin(), in.size()),
Chaos::Service::ChaosException,
{
ASSERT_EQ("Arc4Crypt: not initialized", ex.GetMessage());
});
}
}