File: crc32_spec.cr

package info (click to toggle)
crystal 1.6.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 18,956 kB
  • sloc: javascript: 1,712; sh: 592; cpp: 541; makefile: 243; ansic: 119; python: 105; xml: 32
file content (16 lines) | stat: -rw-r--r-- 474 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
require "spec"
require "digest/crc32"

describe Digest::CRC32 do
  it "should be able to calculate crc32" do
    crc = Digest::CRC32.checksum("foo").to_s(16)
    crc.should eq("8c736521")
  end

  it "should be able to calculate crc32 combined" do
    crc1 = Digest::CRC32.checksum("hello")
    crc2 = Digest::CRC32.checksum(" world!")
    combined = Digest::CRC32.combine(crc1, crc2, " world!".size)
    Digest::CRC32.checksum("hello world!").should eq(combined)
  end
end