Sha256: 687987502cb828282eb8c87b91dd7f31cbbbcc39a14c8d099946e15c37c5547e
Contents?: true
Size: 835 Bytes
Versions: 67
Compression:
Stored size: 835 Bytes
Contents
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
67 entries across 67 versions & 1 rubygems