using System.Text;
using AcDream.Content.Pak;
namespace AcDream.Content.Tests;
///
/// Known-answer vectors for the hand-rolled CRC-32 (IEEE 802.3 / zip / PNG
/// variant). Without these the suite is blind to a self-consistent-but-wrong
/// implementation: writer and reader would agree with each other while
/// producing values no external tool could reproduce (review finding 6).
///
public class Crc32Tests {
[Fact]
public void KnownAnswer_123456789_IsCBF43926() {
// THE standard CRC-32 check value: CRC of the ASCII string
// "123456789" is 0xCBF43926 for the reflected 0xEDB88320 polynomial.
var input = Encoding.ASCII.GetBytes("123456789");
Assert.Equal(0xCBF43926u, Crc32.Compute(input));
}
[Fact]
public void KnownAnswer_EmptyInput_IsZero() {
Assert.Equal(0x00000000u, Crc32.Compute(ReadOnlySpan.Empty));
}
[Fact]
public void KnownAnswer_SingleZeroByte() {
// CRC-32 of a single 0x00 byte is 0xD202EF8D (standard vector).
Assert.Equal(0xD202EF8Du, Crc32.Compute(new byte[] { 0x00 }));
}
}