From d8f2fbf5a82505b5d33e5d8a37fabafd19244aa7 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Fri, 11 Nov 2016 01:13:51 +0100 Subject: Solve acronym --- go/acronym/acronym_test.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 go/acronym/acronym_test.go (limited to 'go/acronym/acronym_test.go') 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) + } + } +} -- cgit v1.2.3