Created
October 4, 2018 01:27
-
-
Save honestcomrade/21b42512cab946aa05e964ed175cc816 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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