Skip to content

Instantly share code, notes, and snippets.

@honestcomrade
Created October 4, 2018 01:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save honestcomrade/21b42512cab946aa05e964ed175cc816 to your computer and use it in GitHub Desktop.
Save honestcomrade/21b42512cab946aa05e964ed175cc816 to your computer and use it in GitHub Desktop.
package main
import "testing"
func TestStringCompression(t *testing.T) {
tables := []struct {
in string // the string to test against
out string // the result of the compression
}{
{"aabbaaacxxxxx", "a2b2a3c1x5"},
{"a", "a"},
{"mmmmnzz", "m4n1z2"},
}
for _, table := range tables {
result := StringCompression(table.in)
if result != table.out {
t.Errorf("Result of ('%v') was incorrect, got: '%v', want: '%v'.", table.in, result, table.out)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment