summaryrefslogtreecommitdiff
path: root/go/word-count/word_count_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'go/word-count/word_count_test.go')
-rw-r--r--go/word-count/word_count_test.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/go/word-count/word_count_test.go b/go/word-count/word_count_test.go
new file mode 100644
index 0000000..98cf6b0
--- /dev/null
+++ b/go/word-count/word_count_test.go
@@ -0,0 +1,31 @@
+package wordcount
+
+import (
+ "reflect"
+ "testing"
+)
+
+const targetTestVersion = 2
+
+func TestWordCount(t *testing.T) {
+ if testVersion != targetTestVersion {
+ t.Fatalf("Found testVersion = %v, want %v", testVersion, targetTestVersion)
+ }
+ for _, tt := range testCases {
+ expected := tt.output
+ actual := WordCount(tt.input)
+ if !reflect.DeepEqual(actual, expected) {
+ t.Fatalf("%s\n\tExpected: %v\n\tGot: %v", tt.description, expected, actual)
+ } else {
+ t.Logf("PASS: %s - WordCount(%s)", tt.description, tt.input)
+ }
+ }
+}
+
+func BenchmarkWordCount(b *testing.B) {
+ for i := 0; i < b.N; i++ {
+ for _, tt := range testCases {
+ WordCount(tt.input)
+ }
+ }
+}