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.1.0.1 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.1.0.0 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.8.55 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.8.54 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.8.53 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.8.52 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.8.51 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.8.50 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.8.49 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.8.48 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.8.47 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.8.46 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.8.45 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.8.44 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.8.43 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.8.42 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.8.41 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.8.40 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.8.39 tracks/ruby/lib/run_length_encoding_cases.rb
trackler-2.0.8.38 tracks/ruby/lib/run_length_encoding_cases.rb