1
0
Fork 0

Add tests for Sort and SlowSort
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Andinus 2020-04-07 01:34:17 +05:30
parent 137618c299
commit 1cd23814d9
Signed by: andinus
GPG Key ID: B67D55D482A799FD
2 changed files with 38 additions and 0 deletions

19
lexical/slowsort_test.go Normal file
View File

@ -0,0 +1,19 @@
package lexical
import "testing"
// TestSlowSort tests the SlowSort func.
func TestSlowSort(t *testing.T) {
words := make(map[string]string)
words["dcba"] = "abcd"
words["zyx"] = "xyz"
for word, sorted := range words {
s := SlowSort(word)
if s != sorted {
t.Errorf("Sort func failed, got %s, want %s",
s, sorted)
}
}
}

19
lexical/sort_test.go Normal file
View File

@ -0,0 +1,19 @@
package lexical
import "testing"
// TestSort tests the Sort func.
func TestSort(t *testing.T) {
words := make(map[string]string)
words["dcba"] = "abcd"
words["zyx"] = "xyz"
for word, sorted := range words {
s := Sort(word)
if s != sorted {
t.Errorf("Sort func failed, got %s, want %s",
s, sorted)
}
}
}