diff options
Diffstat (limited to 'lexical')
-rw-r--r-- | lexical/slowsort_test.go | 19 | ||||
-rw-r--r-- | lexical/sort_test.go | 19 |
2 files changed, 38 insertions, 0 deletions
diff --git a/lexical/slowsort_test.go b/lexical/slowsort_test.go new file mode 100644 index 0000000..20e1a3c --- /dev/null +++ b/lexical/slowsort_test.go @@ -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) + } + } +} diff --git a/lexical/sort_test.go b/lexical/sort_test.go new file mode 100644 index 0000000..c4a823e --- /dev/null +++ b/lexical/sort_test.go @@ -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) + } + } +} |