PadderIso7816: Do not allow to pad empty ranges.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include <algorithm>
|
||||
#include <gtest/gtest.h>
|
||||
#include "TestHelpers/AssertThrowEx.hpp"
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
@@ -8,6 +9,7 @@
|
||||
|
||||
#include "Padding/PadderIso7816.hpp"
|
||||
#include "Padding/Padder.hpp"
|
||||
#include "Service/ChaosException.hpp"
|
||||
|
||||
using namespace Chaos::Padding;
|
||||
|
||||
@@ -45,7 +47,7 @@ TEST(PadIso7816Tests, PadTest)
|
||||
ASSERT_EQ(expected, fact);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 256; ++i)
|
||||
for (int i = 1; i < 256; ++i)
|
||||
{
|
||||
std::vector<uint8_t> fact(i, 0xff);
|
||||
|
||||
@@ -58,6 +60,19 @@ TEST(PadIso7816Tests, PadTest)
|
||||
}
|
||||
}
|
||||
|
||||
TEST(PadIso7816Tests, PadInvalidRangeTest)
|
||||
{
|
||||
{
|
||||
std::array<uint8_t, 3> out = {};
|
||||
|
||||
ASSERT_THROW_EX(PadderIso7816::Pad(out.begin(), out.begin()),
|
||||
Chaos::Service::ChaosException,
|
||||
{
|
||||
ASSERT_EQ("PadderIso7816::Pad(): invalid range", ex.GetMessage());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
TEST(PadIso7816Tests, PadOutIteratorUsageTest)
|
||||
{
|
||||
{
|
||||
@@ -92,22 +107,6 @@ TEST(PadIso7816Tests, PadOutIteratorUsageTest)
|
||||
PadderIso7816::Pad(fact.begin() + 3, fact.end() - 3);
|
||||
ASSERT_EQ(expected, fact);
|
||||
}
|
||||
|
||||
{
|
||||
std::array<uint8_t, 10> fact =
|
||||
{
|
||||
0xbb, 0xbb, 0xbb, 0xbb, 0xbb,
|
||||
0xbb, 0xbb, 0xbb, 0xbb, 0xbb
|
||||
};
|
||||
std::array<uint8_t, 10> expected =
|
||||
{
|
||||
0xbb, 0xbb, 0xbb, 0xbb, 0xbb,
|
||||
0xbb, 0xbb, 0xbb, 0xbb, 0xbb
|
||||
};
|
||||
|
||||
PadderIso7816::Pad(fact.begin() + 5, fact.begin() + 5);
|
||||
ASSERT_EQ(expected, fact);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Impl, typename OutputIt>
|
||||
|
||||
Reference in New Issue
Block a user