summaryrefslogtreecommitdiff
path: root/go/acronym/acronym_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'go/acronym/acronym_test.go')
-rw-r--r--go/acronym/acronym_test.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/go/acronym/acronym_test.go b/go/acronym/acronym_test.go
new file mode 100644
index 0000000..d68fcd6
--- /dev/null
+++ b/go/acronym/acronym_test.go
@@ -0,0 +1,36 @@
+package acronym
+
+import (
+ "testing"
+)
+
+const targetTestVersion = 1
+
+type testCase struct {
+ input string
+ expected string
+}
+
+var stringTestCases = []testCase{
+ {"Portable Network Graphics", "PNG"},
+ {"HyperText Markup Language", "HTML"},
+ {"Ruby on Rails", "ROR"},
+ {"PHP: Hypertext Preprocessor", "PHP"},
+ {"First In, First Out", "FIFO"},
+ {"Complementary metal-oxide semiconductor", "CMOS"},
+}
+
+func TestTestVersion(t *testing.T) {
+ if testVersion != targetTestVersion {
+ t.Errorf("Found testVersion = %v, want %v.", testVersion, targetTestVersion)
+ }
+}
+
+func TestAcronym(t *testing.T) {
+ for _, test := range stringTestCases {
+ actual := abbreviate(test.input)
+ if actual != test.expected {
+ t.Errorf("Acronym test [%s], expected [%s], actual [%s]", test.input, test.expected, actual)
+ }
+ }
+}