From da96f721af60378e128673b54c837f3d2d3e5f2a Mon Sep 17 00:00:00 2001 From: Samuel Lucas <63159663+samuel-lucas6@users.noreply.github.com> Date: Sat, 17 Aug 2024 15:23:27 +0100 Subject: [PATCH] src: Improve some test names. --- src/Geralt.Tests/BLAKE2bTests.cs | 4 ++-- src/Geralt.Tests/Ed25519Tests.cs | 4 ++-- src/Geralt.Tests/EncodingsTests.cs | 4 ++-- src/Geralt.Tests/SpansTests.cs | 2 +- src/Geralt.Tests/X25519Tests.cs | 4 ++-- src/Geralt.Tests/XChaCha20Poly1305Tests.cs | 8 ++++---- src/Geralt.Tests/XChaCha20Tests.cs | 10 +++++----- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Geralt.Tests/BLAKE2bTests.cs b/src/Geralt.Tests/BLAKE2bTests.cs index 1f9254c..696b488 100644 --- a/src/Geralt.Tests/BLAKE2bTests.cs +++ b/src/Geralt.Tests/BLAKE2bTests.cs @@ -157,7 +157,7 @@ public void ComputeHash_Valid(string hash, string message) [TestMethod] [DynamicData(nameof(UnkeyedTestVectors), DynamicDataSourceType.Method)] - public void ComputeHashStream_Valid(string hash, string message) + public void ComputeHash_Stream_Valid(string hash, string message) { Span h = stackalloc byte[hash.Length / 2]; using var m = new MemoryStream(Convert.FromHexString(message), writable: false); @@ -182,7 +182,7 @@ public void ComputeHash_Invalid(int hashSize, int messageSize) [DataRow(BLAKE2b.MaxHashSize + 1, 1)] [DataRow(BLAKE2b.MinHashSize - 1, 1)] [DataRow(BLAKE2b.MaxHashSize, 0)] - public void ComputeHashStream_Invalid(int hashSize, int messageSize) + public void ComputeHash_Stream_Invalid(int hashSize, int messageSize) { var h = new byte[hashSize]; diff --git a/src/Geralt.Tests/Ed25519Tests.cs b/src/Geralt.Tests/Ed25519Tests.cs index 7b86f18..e21a3ce 100644 --- a/src/Geralt.Tests/Ed25519Tests.cs +++ b/src/Geralt.Tests/Ed25519Tests.cs @@ -137,7 +137,7 @@ public void GenerateKeyPair_Invalid(int publicKeySize, int privateKeySize) [TestMethod] [DataRow("b5076a8474a832daee4dd5b4040983b6623b5f344aca57d4d6ee4baf3f259e6e", "421151a459faeade3d247115f94aedae42318124095afabe4d1451a559faedeeb5076a8474a832daee4dd5b4040983b6623b5f344aca57d4d6ee4baf3f259e6e", "421151a459faeade3d247115f94aedae42318124095afabe4d1451a559faedee")] - public void GenerateKeyPairSeeded_Valid(string publicKey, string privateKey, string seed) + public void GenerateKeyPair_Seeded_Valid(string publicKey, string privateKey, string seed) { Span pk = stackalloc byte[Ed25519.PublicKeySize]; Span sk = stackalloc byte[Ed25519.PrivateKeySize]; @@ -153,7 +153,7 @@ public void GenerateKeyPairSeeded_Valid(string publicKey, string privateKey, str [DynamicData(nameof(KeyPairInvalidParameterSizes), DynamicDataSourceType.Method)] [DataRow(Ed25519.PublicKeySize, Ed25519.PrivateKeySize, Ed25519.SeedSize + 1)] [DataRow(Ed25519.PublicKeySize, Ed25519.PrivateKeySize, Ed25519.SeedSize - 1)] - public void GenerateKeyPairSeeded_Invalid(int publicKeySize, int privateKeySize, int seedSize = Ed25519.SeedSize) + public void GenerateKeyPair_Seeded_Invalid(int publicKeySize, int privateKeySize, int seedSize = Ed25519.SeedSize) { var pk = new byte[publicKeySize]; var sk = new byte[privateKeySize]; diff --git a/src/Geralt.Tests/EncodingsTests.cs b/src/Geralt.Tests/EncodingsTests.cs index 89419ab..64a3af9 100644 --- a/src/Geralt.Tests/EncodingsTests.cs +++ b/src/Geralt.Tests/EncodingsTests.cs @@ -62,7 +62,7 @@ public void FromHex_Valid(string data, string hex, string ignoreChars) [DataRow("")] [DataRow("Zg==")] [DataRow("66/6f/6f")] - public void FromHex_Invalid(string hex) + public void FromHex_Invalid(string? hex) { if (hex == null) { Assert.ThrowsException(() => Encodings.FromHex(hex)); @@ -123,7 +123,7 @@ public void FromBase64_Valid(string base64, string data, Encodings.Base64Variant [DataRow("PDw_Pz8-Pg", Encodings.Base64Variant.Url)] [DataRow("PDw/Pz8+Pg", Encodings.Base64Variant.UrlNoPadding)] [DataRow("PDw_Pz8-Pg==", Encodings.Base64Variant.UrlNoPadding)] - public void FromBase64_Invalid(string base64, Encodings.Base64Variant variant) + public void FromBase64_Invalid(string? base64, Encodings.Base64Variant variant) { if (base64 == null) { Assert.ThrowsException(() => Encodings.FromBase64(base64, variant)); diff --git a/src/Geralt.Tests/SpansTests.cs b/src/Geralt.Tests/SpansTests.cs index f346ada..c64b019 100644 --- a/src/Geralt.Tests/SpansTests.cs +++ b/src/Geralt.Tests/SpansTests.cs @@ -42,7 +42,7 @@ public void Concat_Valid() } [TestMethod] - public void ConcatEmpty_Valid() + public void Concat_Empty_Valid() { var buffer = Span.Empty; var parameters = new List diff --git a/src/Geralt.Tests/X25519Tests.cs b/src/Geralt.Tests/X25519Tests.cs index b9de182..5787764 100644 --- a/src/Geralt.Tests/X25519Tests.cs +++ b/src/Geralt.Tests/X25519Tests.cs @@ -146,7 +146,7 @@ public void GenerateKeyPair_Invalid(int publicKeySize, int privateKeySize) [TestMethod] [DataRow("10c84ef255d4682177b9d0b43d753552fbc6b0f2cf735e6b45cba18fa1f05444", "471cfd04edcbcb7f4174a88e9c9569b9aa9464254c3d5373ff6775cb22e7483f", "b589764bb6395e13788436f93f4eaa4c858900b6a12328e8626ded5b39d2c7e9")] - public void GenerateKeyPairSeeded_Valid(string publicKey, string privateKey, string seed) + public void GenerateKeyPair_Seeded_Valid(string publicKey, string privateKey, string seed) { Span pk = stackalloc byte[X25519.PublicKeySize]; Span sk = stackalloc byte[X25519.PrivateKeySize]; @@ -162,7 +162,7 @@ public void GenerateKeyPairSeeded_Valid(string publicKey, string privateKey, str [DynamicData(nameof(KeyPairInvalidParameterSizes), DynamicDataSourceType.Method)] [DataRow(X25519.PublicKeySize, X25519.PrivateKeySize, X25519.SeedSize + 1)] [DataRow(X25519.PublicKeySize, X25519.PrivateKeySize, X25519.SeedSize - 1)] - public void GenerateKeyPairSeeded_Invalid(int publicKeySize, int privateKeySize, int seedSize = X25519.SeedSize) + public void GenerateKeyPair_Seeded_Invalid(int publicKeySize, int privateKeySize, int seedSize = X25519.SeedSize) { var pk = new byte[publicKeySize]; var sk = new byte[privateKeySize]; diff --git a/src/Geralt.Tests/XChaCha20Poly1305Tests.cs b/src/Geralt.Tests/XChaCha20Poly1305Tests.cs index 5ae8695..50f2810 100644 --- a/src/Geralt.Tests/XChaCha20Poly1305Tests.cs +++ b/src/Geralt.Tests/XChaCha20Poly1305Tests.cs @@ -4,7 +4,7 @@ namespace Geralt.Tests; public class XChaCha20Poly1305Tests { // https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha#appendix-A.3.1 - public static IEnumerable DraftXChaChaTestVectors() + public static IEnumerable InternetDraftTestVectors() { yield return new object[] { @@ -73,7 +73,7 @@ public void Incremental_Constants_Valid() } [TestMethod] - [DynamicData(nameof(DraftXChaChaTestVectors), DynamicDataSourceType.Method)] + [DynamicData(nameof(InternetDraftTestVectors), DynamicDataSourceType.Method)] public void Encrypt_Valid(string ciphertext, string plaintext, string nonce, string key, string associatedData) { Span c = stackalloc byte[ciphertext.Length / 2]; @@ -101,7 +101,7 @@ public void Encrypt_Invalid(int ciphertextSize, int plaintextSize, int nonceSize } [TestMethod] - [DynamicData(nameof(DraftXChaChaTestVectors), DynamicDataSourceType.Method)] + [DynamicData(nameof(InternetDraftTestVectors), DynamicDataSourceType.Method)] public void Decrypt_Valid(string ciphertext, string plaintext, string nonce, string key, string associatedData) { Span p = stackalloc byte[plaintext.Length / 2]; @@ -116,7 +116,7 @@ public void Decrypt_Valid(string ciphertext, string plaintext, string nonce, str } [TestMethod] - [DynamicData(nameof(DraftXChaChaTestVectors), DynamicDataSourceType.Method)] + [DynamicData(nameof(InternetDraftTestVectors), DynamicDataSourceType.Method)] public void Decrypt_Tampered(string ciphertext, string plaintext, string nonce, string key, string associatedData) { var p = new byte[plaintext.Length / 2]; diff --git a/src/Geralt.Tests/XChaCha20Tests.cs b/src/Geralt.Tests/XChaCha20Tests.cs index a6e0213..78eea87 100644 --- a/src/Geralt.Tests/XChaCha20Tests.cs +++ b/src/Geralt.Tests/XChaCha20Tests.cs @@ -4,7 +4,7 @@ namespace Geralt.Tests; public class XChaCha20Tests { // https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha#appendix-A.3.1 - public static IEnumerable DraftXChaChaFillTestVectors() + public static IEnumerable InternetDraftFillTestVectors() { yield return new object[] { @@ -24,7 +24,7 @@ public static IEnumerable FillInvalidParameterSizes() } // https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha#appendix-A.3.2 - public static IEnumerable DraftXChaChaEncryptTestVectors() + public static IEnumerable InternetDraftEncryptTestVectors() { yield return new object[] { @@ -64,7 +64,7 @@ public void Constants_Valid() } [TestMethod] - [DynamicData(nameof(DraftXChaChaFillTestVectors), DynamicDataSourceType.Method)] + [DynamicData(nameof(InternetDraftFillTestVectors), DynamicDataSourceType.Method)] public void Fill_Valid(string buffer, string nonce, string key) { Span b = stackalloc byte[buffer.Length / 2]; @@ -88,7 +88,7 @@ public void Fill_Invalid(int bufferSize, int nonceSize, int keySize) } [TestMethod] - [DynamicData(nameof(DraftXChaChaEncryptTestVectors), DynamicDataSourceType.Method)] + [DynamicData(nameof(InternetDraftEncryptTestVectors), DynamicDataSourceType.Method)] public void Encrypt_Valid(string ciphertext, string plaintext, string nonce, string key, ulong counter) { Span c = stackalloc byte[ciphertext.Length / 2]; @@ -119,7 +119,7 @@ public void Encrypt_Invalid(int ciphertextSize, int plaintextSize, int nonceSize } [TestMethod] - [DynamicData(nameof(DraftXChaChaEncryptTestVectors), DynamicDataSourceType.Method)] + [DynamicData(nameof(InternetDraftEncryptTestVectors), DynamicDataSourceType.Method)] public void Decrypt_Valid(string ciphertext, string plaintext, string nonce, string key, ulong counter) { Span p = stackalloc byte[plaintext.Length / 2];