Sha256: 9a72a2a362cf728521cc986981c0ef3acf3aa2885a7fd12f8fe46f1e0d4f5f88

Contents?: true

Size: 861 Bytes

Versions: 90

Compression:

Stored size: 861 Bytes

Contents

require 'exercise_cases'

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

90 entries across 90 versions & 1 rubygems

Version Path
trackler-2.0.6.41 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.6.40 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.6.39 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.6.38 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.6.37 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.6.36 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.6.35 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.6.34 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.6.33 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.6.32 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.6.31 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.6.30 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.6.29 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.6.28 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.6.27 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.6.26 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.6.25 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.6.24 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.6.23 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.6.22 tracks/ruby/lib/run_length_encoding_cases.rb