Sha256: 0ae5a00a76bc6cb72f0565449681e9ea024405eed73b903b9e3e2b4e167088b6

Contents?: true

Size: 742 Bytes

Versions: 7

Compression:

Stored size: 742 Bytes

Contents

require 'spec_helper'

describe FormatParser do
  it 'returns nil when trying to parse an empty IO' do
    d = StringIO.new('')
    expect(FormatParser.parse(d)).to be_nil
  end

  it 'returns nil when parsing an IO no parser can make sense of' do
    d = StringIO.new(Random.new.bytes(1))
    expect(FormatParser.parse(d)).to be_nil
  end

  describe 'with fuzzing' do
    it "returns either a valid result or a nil for all fuzzed inputs at seed #{RSpec.configuration.seed}" do
      r = Random.new(RSpec.configuration.seed)
      1024.times do
        random_blob = StringIO.new(r.bytes(512 * 1024))
        FormatParser.parse(random_blob) # If there is an error in one of the parsers the example will raise too
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
format_parser-0.1.6 spec/format_parser_spec.rb
format_parser-0.1.5 spec/format_parser_spec.rb
format_parser-0.1.4 spec/format_parser_spec.rb
format_parser-0.1.3 spec/format_parser_spec.rb
format_parser-0.1.2 spec/format_parser_spec.rb
format_parser-0.1.1 spec/format_parser_spec.rb
format_parser-0.1.0 spec/format_parser_spec.rb