Skip to content

Commit

Permalink
src: Improve some test names.
Browse files Browse the repository at this point in the history
  • Loading branch information
samuel-lucas6 committed Aug 17, 2024
1 parent 220e788 commit da96f72
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/Geralt.Tests/BLAKE2bTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<byte> h = stackalloc byte[hash.Length / 2];
using var m = new MemoryStream(Convert.FromHexString(message), writable: false);
Expand All @@ -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];

Expand Down
4 changes: 2 additions & 2 deletions src/Geralt.Tests/Ed25519Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<byte> pk = stackalloc byte[Ed25519.PublicKeySize];
Span<byte> sk = stackalloc byte[Ed25519.PrivateKeySize];
Expand All @@ -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];
Expand Down
4 changes: 2 additions & 2 deletions src/Geralt.Tests/EncodingsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ArgumentNullException>(() => Encodings.FromHex(hex));

Check warning on line 68 in src/Geralt.Tests/EncodingsTests.cs

View workflow job for this annotation

GitHub Actions / test-windows-x64

Possible null reference argument for parameter 'hex' in 'byte[] Encodings.FromHex(string hex, string ignoreChars = ":- ")'.

Check warning on line 68 in src/Geralt.Tests/EncodingsTests.cs

View workflow job for this annotation

GitHub Actions / test-windows-x64

Possible null reference argument for parameter 'hex' in 'byte[] Encodings.FromHex(string hex, string ignoreChars = ":- ")'.

Check warning on line 68 in src/Geralt.Tests/EncodingsTests.cs

View workflow job for this annotation

GitHub Actions / test-windows-x64

Possible null reference argument for parameter 'hex' in 'byte[] Encodings.FromHex(string hex, string ignoreChars = ":- ")'.

Check warning on line 68 in src/Geralt.Tests/EncodingsTests.cs

View workflow job for this annotation

GitHub Actions / test-windows-x64

Possible null reference argument for parameter 'hex' in 'byte[] Encodings.FromHex(string hex, string ignoreChars = ":- ")'.

Check warning on line 68 in src/Geralt.Tests/EncodingsTests.cs

View workflow job for this annotation

GitHub Actions / test-linux-x64

Possible null reference argument for parameter 'hex' in 'byte[] Encodings.FromHex(string hex, string ignoreChars = ":- ")'.

Check warning on line 68 in src/Geralt.Tests/EncodingsTests.cs

View workflow job for this annotation

GitHub Actions / test-linux-x64

Possible null reference argument for parameter 'hex' in 'byte[] Encodings.FromHex(string hex, string ignoreChars = ":- ")'.

Check warning on line 68 in src/Geralt.Tests/EncodingsTests.cs

View workflow job for this annotation

GitHub Actions / test-linux-x64

Possible null reference argument for parameter 'hex' in 'byte[] Encodings.FromHex(string hex, string ignoreChars = ":- ")'.

Check warning on line 68 in src/Geralt.Tests/EncodingsTests.cs

View workflow job for this annotation

GitHub Actions / test-linux-x64

Possible null reference argument for parameter 'hex' in 'byte[] Encodings.FromHex(string hex, string ignoreChars = ":- ")'.

Check warning on line 68 in src/Geralt.Tests/EncodingsTests.cs

View workflow job for this annotation

GitHub Actions / test-macos-x64

Possible null reference argument for parameter 'hex' in 'byte[] Encodings.FromHex(string hex, string ignoreChars = ":- ")'.

Check warning on line 68 in src/Geralt.Tests/EncodingsTests.cs

View workflow job for this annotation

GitHub Actions / test-macos-x64

Possible null reference argument for parameter 'hex' in 'byte[] Encodings.FromHex(string hex, string ignoreChars = ":- ")'.

Check warning on line 68 in src/Geralt.Tests/EncodingsTests.cs

View workflow job for this annotation

GitHub Actions / test-macos-x64

Possible null reference argument for parameter 'hex' in 'byte[] Encodings.FromHex(string hex, string ignoreChars = ":- ")'.

Check warning on line 68 in src/Geralt.Tests/EncodingsTests.cs

View workflow job for this annotation

GitHub Actions / test-macos-x64

Possible null reference argument for parameter 'hex' in 'byte[] Encodings.FromHex(string hex, string ignoreChars = ":- ")'.
Expand Down Expand Up @@ -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<ArgumentNullException>(() => Encodings.FromBase64(base64, variant));

Check warning on line 129 in src/Geralt.Tests/EncodingsTests.cs

View workflow job for this annotation

GitHub Actions / test-windows-x64

Possible null reference argument for parameter 'base64' in 'byte[] Encodings.FromBase64(string base64, Base64Variant variant = Base64Variant.Original, string ignoreChars = " ")'.

Check warning on line 129 in src/Geralt.Tests/EncodingsTests.cs

View workflow job for this annotation

GitHub Actions / test-windows-x64

Possible null reference argument for parameter 'base64' in 'byte[] Encodings.FromBase64(string base64, Base64Variant variant = Base64Variant.Original, string ignoreChars = " ")'.

Check warning on line 129 in src/Geralt.Tests/EncodingsTests.cs

View workflow job for this annotation

GitHub Actions / test-windows-x64

Possible null reference argument for parameter 'base64' in 'byte[] Encodings.FromBase64(string base64, Base64Variant variant = Base64Variant.Original, string ignoreChars = " ")'.

Check warning on line 129 in src/Geralt.Tests/EncodingsTests.cs

View workflow job for this annotation

GitHub Actions / test-windows-x64

Possible null reference argument for parameter 'base64' in 'byte[] Encodings.FromBase64(string base64, Base64Variant variant = Base64Variant.Original, string ignoreChars = " ")'.

Check warning on line 129 in src/Geralt.Tests/EncodingsTests.cs

View workflow job for this annotation

GitHub Actions / test-linux-x64

Possible null reference argument for parameter 'base64' in 'byte[] Encodings.FromBase64(string base64, Base64Variant variant = Base64Variant.Original, string ignoreChars = " ")'.

Check warning on line 129 in src/Geralt.Tests/EncodingsTests.cs

View workflow job for this annotation

GitHub Actions / test-linux-x64

Possible null reference argument for parameter 'base64' in 'byte[] Encodings.FromBase64(string base64, Base64Variant variant = Base64Variant.Original, string ignoreChars = " ")'.

Check warning on line 129 in src/Geralt.Tests/EncodingsTests.cs

View workflow job for this annotation

GitHub Actions / test-linux-x64

Possible null reference argument for parameter 'base64' in 'byte[] Encodings.FromBase64(string base64, Base64Variant variant = Base64Variant.Original, string ignoreChars = " ")'.

Check warning on line 129 in src/Geralt.Tests/EncodingsTests.cs

View workflow job for this annotation

GitHub Actions / test-linux-x64

Possible null reference argument for parameter 'base64' in 'byte[] Encodings.FromBase64(string base64, Base64Variant variant = Base64Variant.Original, string ignoreChars = " ")'.

Check warning on line 129 in src/Geralt.Tests/EncodingsTests.cs

View workflow job for this annotation

GitHub Actions / test-macos-x64

Possible null reference argument for parameter 'base64' in 'byte[] Encodings.FromBase64(string base64, Base64Variant variant = Base64Variant.Original, string ignoreChars = " ")'.

Check warning on line 129 in src/Geralt.Tests/EncodingsTests.cs

View workflow job for this annotation

GitHub Actions / test-macos-x64

Possible null reference argument for parameter 'base64' in 'byte[] Encodings.FromBase64(string base64, Base64Variant variant = Base64Variant.Original, string ignoreChars = " ")'.

Check warning on line 129 in src/Geralt.Tests/EncodingsTests.cs

View workflow job for this annotation

GitHub Actions / test-macos-x64

Possible null reference argument for parameter 'base64' in 'byte[] Encodings.FromBase64(string base64, Base64Variant variant = Base64Variant.Original, string ignoreChars = " ")'.

Check warning on line 129 in src/Geralt.Tests/EncodingsTests.cs

View workflow job for this annotation

GitHub Actions / test-macos-x64

Possible null reference argument for parameter 'base64' in 'byte[] Encodings.FromBase64(string base64, Base64Variant variant = Base64Variant.Original, string ignoreChars = " ")'.
Expand Down
2 changes: 1 addition & 1 deletion src/Geralt.Tests/SpansTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void Concat_Valid()
}

[TestMethod]
public void ConcatEmpty_Valid()
public void Concat_Empty_Valid()
{
var buffer = Span<byte>.Empty;
var parameters = new List<byte[]>
Expand Down
4 changes: 2 additions & 2 deletions src/Geralt.Tests/X25519Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<byte> pk = stackalloc byte[X25519.PublicKeySize];
Span<byte> sk = stackalloc byte[X25519.PrivateKeySize];
Expand All @@ -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];
Expand Down
8 changes: 4 additions & 4 deletions src/Geralt.Tests/XChaCha20Poly1305Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<object[]> DraftXChaChaTestVectors()
public static IEnumerable<object[]> InternetDraftTestVectors()
{
yield return new object[]
{
Expand Down Expand Up @@ -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<byte> c = stackalloc byte[ciphertext.Length / 2];
Expand Down Expand Up @@ -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<byte> p = stackalloc byte[plaintext.Length / 2];
Expand All @@ -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];
Expand Down
10 changes: 5 additions & 5 deletions src/Geralt.Tests/XChaCha20Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<object[]> DraftXChaChaFillTestVectors()
public static IEnumerable<object[]> InternetDraftFillTestVectors()
{
yield return new object[]
{
Expand All @@ -24,7 +24,7 @@ public static IEnumerable<object[]> FillInvalidParameterSizes()
}

// https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha#appendix-A.3.2
public static IEnumerable<object[]> DraftXChaChaEncryptTestVectors()
public static IEnumerable<object[]> InternetDraftEncryptTestVectors()
{
yield return new object[]
{
Expand Down Expand Up @@ -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<byte> b = stackalloc byte[buffer.Length / 2];
Expand All @@ -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<byte> c = stackalloc byte[ciphertext.Length / 2];
Expand Down Expand Up @@ -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<byte> p = stackalloc byte[plaintext.Length / 2];
Expand Down

0 comments on commit da96f72

Please sign in to comment.