From b34fda75efb83f44bc5ac3385004d25d979f36fb Mon Sep 17 00:00:00 2001 From: hashlag Date: Wed, 4 Feb 2026 23:37:05 +0300 Subject: [PATCH] DesCryptTests: IteratorUsage tests: Add testcases with begin == end. --- ChaosTests/Cipher/DesCryptTests.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/ChaosTests/Cipher/DesCryptTests.cpp b/ChaosTests/Cipher/DesCryptTests.cpp index 31ef191..94c06e7 100644 --- a/ChaosTests/Cipher/DesCryptTests.cpp +++ b/ChaosTests/Cipher/DesCryptTests.cpp @@ -406,6 +406,20 @@ TEST(DesCryptTests, OutIteratorUsageEncryptTest) ASSERT_EQ(expected, fact); } + + { + std::array data = { 0xe5, 0x1a, 0x9f, 0xd4, 0x19, 0xa7, 0x93, 0x44, 0x44, 0x44 }; + std::array key = { 0xda, 0xec, 0x68, 0xae, 0x83, 0xe0, 0x1e, 0xab }; + + std::array fact = {}; + std::array expected = {}; + + DesCrypt::Key desKey(key.begin(), key.end()); + DesCrypt::DesEncryptor enc(desKey); + enc.EncryptBlock(fact.begin() + 3, fact.begin() + 3, data.begin(), data.end()); + + ASSERT_EQ(expected, fact); + } } TEST(DesCryptTests, OutIteratorUsageDecryptTest) @@ -439,6 +453,20 @@ TEST(DesCryptTests, OutIteratorUsageDecryptTest) ASSERT_EQ(expected, fact); } + + { + std::array data = { 0xe5, 0x1a, 0x9f, 0xd4, 0x19, 0xa7, 0x93, 0x44, 0x44, 0x44 }; + std::array key = { 0xda, 0xec, 0x68, 0xae, 0x83, 0xe0, 0x1e, 0xab }; + + std::array fact = {}; + std::array expected = {}; + + DesCrypt::Key desKey(key.begin(), key.end()); + DesCrypt::DesDecryptor dec(desKey); + dec.DecryptBlock(fact.begin() + 3, fact.begin() + 3, data.begin(), data.end()); + + ASSERT_EQ(expected, fact); + } } template