diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-02-14 00:39:03 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-02-14 00:39:03 +0700 |
commit | cf6d2bb3cfc2abdacdd30ef2a8b6903c81f179dd (patch) | |
tree | 98ff90baeff3bde19173da620125700c281b9293 | |
parent | Rework AsconEngine (diff) | |
download | BouncyCastle.NET-ed25519-cf6d2bb3cfc2abdacdd30ef2a8b6903c81f179dd.tar.xz |
Refactor LWC tests
-rw-r--r-- | crypto/test/src/crypto/test/ISAPTest.cs | 8 | ||||
-rw-r--r-- | crypto/test/src/crypto/test/PhotonBeetleTest.cs | 16 | ||||
-rw-r--r-- | crypto/test/src/crypto/test/XoodyakTest.cs | 8 |
3 files changed, 13 insertions, 19 deletions
diff --git a/crypto/test/src/crypto/test/ISAPTest.cs b/crypto/test/src/crypto/test/ISAPTest.cs index 500026bf9..38cf7c633 100644 --- a/crypto/test/src/crypto/test/ISAPTest.cs +++ b/crypto/test/src/crypto/test/ISAPTest.cs @@ -458,12 +458,10 @@ namespace Org.BouncyCastle.Crypto.Tests "GetOutputSize of " + isapEngine.AlgorithmName + " is incorrect for decryption"); } - private void ImplTestExceptions(IsapDigest isapDigest, int digestsize) + private void ImplTestExceptions(IsapDigest isapDigest, int digestSize) { - if (isapDigest.GetDigestSize() != digestsize) - { - Assert.Fail(isapDigest.AlgorithmName + ": digest size is not correct"); - } + Assert.AreEqual(digestSize, isapDigest.GetDigestSize(), + isapDigest.AlgorithmName + ": digest size is not correct"); try { diff --git a/crypto/test/src/crypto/test/PhotonBeetleTest.cs b/crypto/test/src/crypto/test/PhotonBeetleTest.cs index cd551432c..b9a648f17 100644 --- a/crypto/test/src/crypto/test/PhotonBeetleTest.cs +++ b/crypto/test/src/crypto/test/PhotonBeetleTest.cs @@ -440,17 +440,15 @@ namespace Org.BouncyCastle.Crypto.Tests } } - private void ImplTestExceptions(IDigest digest, int digestsize) + private void ImplTestExceptions(PhotonBeetleDigest photonBeetleDigest, int digestSize) { - if (digest.GetDigestSize() != digestsize) - { - Assert.Fail(digest.AlgorithmName + ": digest size is not correct"); - } + Assert.AreEqual(digestSize, photonBeetleDigest.GetDigestSize(), + photonBeetleDigest.AlgorithmName + ": digest size is not correct"); try { - digest.BlockUpdate(new byte[1], 1, 1); - Assert.Fail(digest.AlgorithmName + ": input for BlockUpdate is too short"); + photonBeetleDigest.BlockUpdate(new byte[1], 1, 1); + Assert.Fail(photonBeetleDigest.AlgorithmName + ": input for BlockUpdate is too short"); } catch (DataLengthException) { @@ -458,8 +456,8 @@ namespace Org.BouncyCastle.Crypto.Tests } try { - digest.DoFinal(new byte[digest.GetDigestSize() - 1], 2); - Assert.Fail(digest.AlgorithmName + ": output for DoFinal is too short"); + photonBeetleDigest.DoFinal(new byte[digestSize - 1], 2); + Assert.Fail(photonBeetleDigest.AlgorithmName + ": output for DoFinal is too short"); } catch (OutputLengthException) { diff --git a/crypto/test/src/crypto/test/XoodyakTest.cs b/crypto/test/src/crypto/test/XoodyakTest.cs index b73d998f4..5cbff7a41 100644 --- a/crypto/test/src/crypto/test/XoodyakTest.cs +++ b/crypto/test/src/crypto/test/XoodyakTest.cs @@ -431,12 +431,10 @@ namespace Org.BouncyCastle.Crypto.Tests } } - private void ImplTestExceptions(XoodyakDigest xoodyakDigest, int digestsize) + private void ImplTestExceptions(XoodyakDigest xoodyakDigest, int digestSize) { - if (xoodyakDigest.GetDigestSize() != digestsize) - { - Assert.Fail(xoodyakDigest.AlgorithmName + ": digest size is not correct"); - } + Assert.AreEqual(digestSize, xoodyakDigest.GetDigestSize(), + xoodyakDigest.AlgorithmName + ": digest size is not correct"); try { |