Sha256: 687987502cb828282eb8c87b91dd7f31cbbbcc39a14c8d099946e15c37c5547e

Contents?: true

Size: 835 Bytes

Versions: 67

Compression:

Stored size: 835 Bytes

Contents

class RunLengthEncodingCase < OpenStruct
  def name
    'test_%s' % cleaned_description
  end

  def assign_input
    "input = '#{input}'"
  end

  def assign_output
    "output = '#{expected}'"
  end

  def assertion
    case description
    when /decode.+encode/
      'assert_equal output,
                 RunLengthEncoding.decode(RunLengthEncoding.encode(input))'
    when /encode/
      'assert_equal output, RunLengthEncoding.encode(input)'
    when /decode/
      'assert_equal output, RunLengthEncoding.decode(input)'
    end
  end

  def skipped?
    index > 0
  end

  # internal

  def cleaned_description
    description.gsub(/\W+/, '_').squeeze('_')
  end
end

RunLengthEncodingCases = proc do |data|
  JSON.parse(data)['cases'].map.with_index do |row, i|
    RunLengthEncodingCase.new(row.merge('index' => i))
  end
end

Version data entries

67 entries across 67 versions & 1 rubygems

Version Path
trackler-2.0.6.11 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.6.10 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.6.9 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.6.8 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.6.7 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.6.6 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.6.5 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.6.4 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.6.3 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.6.2 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.6.1 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.6.0 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.5.18 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.5.17 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.5.16 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.5.15 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.5.14 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.5.13 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.5.12 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.5.11 tracks/ruby/lib/run_length_encoding_cases.rb