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.86 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.85 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.84 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.83 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.82 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.81 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.80 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.79 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.78 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.77 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.76 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.75 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.74 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.73 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.72 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.71 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.70 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.69 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.68 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.67 tracks/crystal/generator/src/generators/run_length_encoding.cr