diff --git a/src/libraries/System.IO.Hashing/tests/NonCryptoHashTestDriver.cs b/src/libraries/System.IO.Hashing/tests/NonCryptoHashTestDriver.cs index 92b0567427fe11..71eed3a8b16e9d 100644 --- a/src/libraries/System.IO.Hashing/tests/NonCryptoHashTestDriver.cs +++ b/src/libraries/System.IO.Hashing/tests/NonCryptoHashTestDriver.cs @@ -309,6 +309,22 @@ public void Clone_ProducesSameSequence() } } + [Fact] + public void AppendingEmptyHasNoEffect() + { + NonCryptographicHashAlgorithm reference = CreateInstance(); + reference.Append(new byte[] { 1, 2, 3 }); + byte[] expected = reference.GetCurrentHash(); + + NonCryptographicHashAlgorithm hash = CreateInstance(); + hash.Append(ReadOnlySpan.Empty); + hash.Append(new byte[] { 1, 2, 3 }); + hash.Append(ReadOnlySpan.Empty); + byte[] actual = hash.GetCurrentHash(); + + Assert.Equal(expected, actual); + } + private void VerifyEmptyResult(ReadOnlySpan result) { if (!result.SequenceEqual(_emptyHash))