Add tests for Sort and SlowSort
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
137618c299
commit
1cd23814d9
|
@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue