summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2020-04-07 01:34:17 +0530
committerAndinus <andinus@nand.sh>2020-04-07 01:34:17 +0530
commit1cd23814d9590880f486f0ed9993216e41733ba9 (patch)
tree2d29ba27ba8760574920d5acee6bc5fad0af4179
parent137618c299728720ca01c32572357e7b8338abf2 (diff)
downloadgrus-1cd23814d9590880f486f0ed9993216e41733ba9.tar.gz
Add tests for Sort and SlowSort
-rw-r--r--lexical/slowsort_test.go19
-rw-r--r--lexical/sort_test.go19
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)
+		}
+	}
+}