test "quick_start_example" {
// Calculate CRC-32 of some data
let data = b"Hello, World!"
let checksum = @crc32.bytes(data)
inspect(checksum, content="0x101995297995110048")
// Verify data integrity
let received_data = b"Hello, World!"
let received_checksum = @crc32.bytes(received_data)
assert_eq(checksum, received_checksum)
}pub(all) struct Crc32(Int64) derive(Eq)test "bytes_function_example" {
let data = b"Hello, CRC32!"
let crc = @crc32.bytes(data)
inspect(crc, content="0x10110150971025110249")
}test "example_basic" {
// Calculate checksum
let message = b"Hello, World!"
let checksum = @crc32.bytes(message)
// Display result
inspect("Message: Hello, World!", content="Message: Hello, World!")
inspect(checksum, content="0x101995297995110048")
}test "example_integrity" {
let original_data = b"Important data"
let expected_crc = @crc32.bytes(original_data)
// Simulate data transmission/storage
let received_data = b"Important data"
let received_crc = @crc32.bytes(received_data)
// Verify integrity
assert_eq(expected_crc, received_crc)
}test "example_data_types" {
// Text data
let text_crc = @crc32.bytes(b"Hello")
// Binary data
let binary_data = Bytes::from_array([0x48, 0x65, 0x6c, 0x6c, 0x6f]) // "Hello" in bytes
let binary_crc = @crc32.bytes(binary_data)
// They should be equal
assert_eq(text_crc, binary_crc)
inspect(text_crc, content="0x102551004956575650")
}test "example_performance" {
let small_data = b"Hello"
let large_data = b"This is a much larger piece of data that will take more time to process but still be very fast with our optimized CRC-32 implementation."
let small_crc = @crc32.bytes(small_data)
let large_crc = @crc32.bytes(large_data)
inspect(small_crc, content="0x102551004956575650")
inspect(large_crc, content="0x49524897525197102")
inspect("Both calculated efficiently!", content="Both calculated efficiently!")
}test "integration_example" {
// Used internally by ZIP operations
let file_data = b"File content"
let file_crc = @crc32.bytes(file_data)
// CRC is automatically included in ZIP file headers
inspect(file_crc, content="0x995610150100495354")
}pub(all) type Crc32 Int64ZIP archive and deflate codec for MoonBit - ported from OCaml zipc library