summaryrefslogtreecommitdiff
path: root/go/run-length-encoding/cases_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'go/run-length-encoding/cases_test.go')
-rw-r--r--go/run-length-encoding/cases_test.go89
1 files changed, 89 insertions, 0 deletions
diff --git a/go/run-length-encoding/cases_test.go b/go/run-length-encoding/cases_test.go
new file mode 100644
index 0000000..38266e9
--- /dev/null
+++ b/go/run-length-encoding/cases_test.go
@@ -0,0 +1,89 @@
+package encode
+
+// This is an auto-generated file. Do not change it manually. Run the generator to update the file.
+// See https://github.com/exercism/go#synchronizing-tests-and-instructions
+// Source: exercism/problem-specifications
+// Commit: a757698 run-length-encoding: 'lower case' -> 'lowercase' (#1708)
+
+type testCase struct {
+ description string
+ input string
+ expected string
+}
+
+// run-length encode a string
+var encodeTests = []testCase{
+ {
+ description: "empty string",
+ input: "",
+ expected: "",
+ },
+ {
+ description: "single characters only are encoded without count",
+ input: "XYZ",
+ expected: "XYZ",
+ },
+ {
+ description: "string with no single characters",
+ input: "AABBBCCCC",
+ expected: "2A3B4C",
+ },
+ {
+ description: "single characters mixed with repeated characters",
+ input: "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB",
+ expected: "12WB12W3B24WB",
+ },
+ {
+ description: "multiple whitespace mixed in string",
+ input: " hsqq qww ",
+ expected: "2 hs2q q2w2 ",
+ },
+ {
+ description: "lowercase characters",
+ input: "aabbbcccc",
+ expected: "2a3b4c",
+ },
+}
+
+// run-length decode a string
+var decodeTests = []testCase{
+ {
+ description: "empty string",
+ input: "",
+ expected: "",
+ },
+ {
+ description: "single characters only",
+ input: "XYZ",
+ expected: "XYZ",
+ },
+ {
+ description: "string with no single characters",
+ input: "2A3B4C",
+ expected: "AABBBCCCC",
+ },
+ {
+ description: "single characters with repeated characters",
+ input: "12WB12W3B24WB",
+ expected: "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB",
+ },
+ {
+ description: "multiple whitespace mixed in string",
+ input: "2 hs2q q2w2 ",
+ expected: " hsqq qww ",
+ },
+ {
+ description: "lowercase string",
+ input: "2a3b4c",
+ expected: "aabbbcccc",
+ },
+}
+
+// encode and then decode
+var encodeDecodeTests = []testCase{
+ {
+ description: "encode followed by decode gives original string",
+ input: "zzz ZZ zZ",
+ expected: "zzz ZZ zZ",
+ },
+}