Sha256: e3eb66b8647f727a9393fb9db902299cddbfabcf8e48873d980c3f8603bfc3f7

Contents?: true

Size: 1.37 KB

Versions: 77

Compression:

Stored size: 1.37 KB

Contents

package encode

// Source: exercism/problem-specifications
// Commit: 1b7900e run-length-encoding: apply "input" policy
// Problem Specifications Version: 1.1.0

// run-length encode a string
var encodeTests = []struct {
	input       string
	expected    string
	description string
}{
	{"", "", "empty string"},
	{"XYZ", "XYZ", "single characters only are encoded without count"},
	{"AABBBCCCC", "2A3B4C", "string with no single characters"},
	{"WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB", "12WB12W3B24WB", "single characters mixed with repeated characters"},
	{"  hsqq qww  ", "2 hs2q q2w2 ", "multiple whitespace mixed in string"},
	{"aabbbcccc", "2a3b4c", "lowercase characters"},
}

// run-length decode a string
var decodeTests = []struct {
	input       string
	expected    string
	description string
}{
	{"", "", "empty string"},
	{"XYZ", "XYZ", "single characters only"},
	{"2A3B4C", "AABBBCCCC", "string with no single characters"},
	{"12WB12W3B24WB", "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB", "single characters with repeated characters"},
	{"2 hs2q q2w2 ", "  hsqq qww  ", "multiple whitespace mixed in string"},
	{"2a3b4c", "aabbbcccc", "lower case string"},
}

// encode and then decode
var encodeDecodeTests = []struct {
	input       string
	expected    string
	description string
}{
	{"zzz ZZ  zZ", "zzz ZZ  zZ", "encode followed by decode gives original string"},
}

Version data entries

77 entries across 77 versions & 1 rubygems

Version Path
trackler-2.2.1.159 tracks/go/exercises/run-length-encoding/cases_test.go
trackler-2.2.1.158 tracks/go/exercises/run-length-encoding/cases_test.go
trackler-2.2.1.157 tracks/go/exercises/run-length-encoding/cases_test.go
trackler-2.2.1.156 tracks/go/exercises/run-length-encoding/cases_test.go
trackler-2.2.1.155 tracks/go/exercises/run-length-encoding/cases_test.go
trackler-2.2.1.154 tracks/go/exercises/run-length-encoding/cases_test.go
trackler-2.2.1.153 tracks/go/exercises/run-length-encoding/cases_test.go
trackler-2.2.1.152 tracks/go/exercises/run-length-encoding/cases_test.go
trackler-2.2.1.151 tracks/go/exercises/run-length-encoding/cases_test.go
trackler-2.2.1.150 tracks/go/exercises/run-length-encoding/cases_test.go
trackler-2.2.1.149 tracks/go/exercises/run-length-encoding/cases_test.go
trackler-2.2.1.148 tracks/go/exercises/run-length-encoding/cases_test.go
trackler-2.2.1.147 tracks/go/exercises/run-length-encoding/cases_test.go
trackler-2.2.1.146 tracks/go/exercises/run-length-encoding/cases_test.go
trackler-2.2.1.145 tracks/go/exercises/run-length-encoding/cases_test.go
trackler-2.2.1.144 tracks/go/exercises/run-length-encoding/cases_test.go
trackler-2.2.1.143 tracks/go/exercises/run-length-encoding/cases_test.go
trackler-2.2.1.142 tracks/go/exercises/run-length-encoding/cases_test.go
trackler-2.2.1.141 tracks/go/exercises/run-length-encoding/cases_test.go
trackler-2.2.1.140 tracks/go/exercises/run-length-encoding/cases_test.go