summaryrefslogtreecommitdiff
path: root/go/acronym/acronym_test.go
blob: d68fcd6e8c94073e9fdbb8d1454c6cb73c8ce208 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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)
		}
	}
}