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
+16 -3
View File
@@ -1,4 +1,5 @@
#include <gtest/gtest.h>
#include "TestHelpers/AssertThrowEx.hpp"
#include <array>
#include <cstdint>
#include <vector>
@@ -57,19 +58,31 @@ TEST(PadPkcs7Tests, PadInvalidRangeTest)
{
std::array<uint8_t, 256> out = {};
ASSERT_THROW(PadderPkcs7::Pad(out.begin(), out.end()), Chaos::Service::ChaosException);
ASSERT_THROW_EX(PadderPkcs7::Pad(out.begin(), out.end()),
Chaos::Service::ChaosException,
{
ASSERT_EQ("PadderPkcs7::Pad(): invalid range", ex.GetMessage());
});
}
{
std::array<uint8_t, 500> out = {};
ASSERT_THROW(PadderPkcs7::Pad(out.begin(), out.end()), Chaos::Service::ChaosException);
ASSERT_THROW_EX(PadderPkcs7::Pad(out.begin(), out.end()),
Chaos::Service::ChaosException,
{
ASSERT_EQ("PadderPkcs7::Pad(): invalid range", ex.GetMessage());
});
}
{
std::array<uint8_t, 50> out = {};
ASSERT_THROW(PadderPkcs7::Pad(out.end(), out.begin()), Chaos::Service::ChaosException);
ASSERT_THROW_EX(PadderPkcs7::Pad(out.end(), out.begin()),
Chaos::Service::ChaosException,
{
ASSERT_EQ("PadderPkcs7::Pad(): invalid range", ex.GetMessage());
});
}
}