Sha256: 9300c02e2827bcaf59e94cc9572af167228499c56356aa85e24ef232a494affd

Contents?: true

Size: 872 Bytes

Versions: 156

Compression:

Stored size: 872 Bytes

Contents

require "../exercise_generator"
require "../exercise_test_case"

class RunLengthEncodingGenerator < ExerciseGenerator
  def exercise_name
    "run-length-encoding"
  end

  def test_cases
    JSON.parse(data)["cases"].map do |test_case|
      RunLengthEncodingTestCase.new(test_case)
    end
  end
end

class RunLengthEncodingTestCase < ExerciseTestCase
  private getter description : JSON::Any
  private getter input : JSON::Any
  private getter expected : JSON::Any

  def initialize(test_case)
    @description = test_case["description"]
    @input = test_case["input"]
    @expected = test_case["expected"]
  end

  def workload
    "RunLengthEncoding.#{method}(\"#{input}\").should eq(\"#{expected}\")"
  end

  def test_name
    description
  end

  private def method
    if description.as_s.match(/encode/)
      "encode"
    else
      "decode"
    end
  end
end

Version data entries

156 entries across 156 versions & 1 rubygems

Version Path
trackler-2.2.1.147 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.146 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.145 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.144 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.143 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.142 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.141 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.140 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.139 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.138 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.137 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.136 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.135 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.134 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.133 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.132 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.131 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.130 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.129 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.128 tracks/crystal/generator/src/generators/run_length_encoding.cr