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.66 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.65 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.64 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.63 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.62 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.61 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.60 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.59 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.58 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.57 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.56 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.55 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.54 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.53 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.52 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.51 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.50 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.49 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.48 tracks/crystal/generator/src/generators/run_length_encoding.cr
trackler-2.2.1.47 tracks/crystal/generator/src/generators/run_length_encoding.cr