Sha256: 4b0a13b93f068d1ef8a877fc20cea355bdd971a80dea8b34cb781a0f1b037253

Contents?: true

Size: 829 Bytes

Versions: 1

Compression:

Stored size: 829 Bytes

Contents

require 'spec_helper'

shared_examples_for "CRC" do
  it "should calculate a checksum for text" do
    expect(described_class.hexdigest(string)).to be == expected
  end

  it "should calculate a checksum for multiple data" do
    middle = (string.length / 2)

    chunk1 = string[0...middle]
    chunk2 = string[middle..-1]

    crc = subject
    crc << chunk1
    crc << chunk2

    expect(crc.hexdigest).to be == expected
  end

  it "should provide direct access to the checksum value" do
    crc = subject
    crc << string

    expect(crc.checksum).to be == expected.to_i(16)
  end

  if defined?(Ractor)
    it "should calculate CRC inside ractor" do
      digest = Ractor.new(described_class, string) do |klass, string|
        klass.hexdigest(string)
      end.take

      expect(digest).to eq expected
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
digest-crc-0.6.5 spec/crc_examples.rb