summaryrefslogtreecommitdiff
path: root/go/word-count/cases_test.go
blob: 204e122b361652298e09fcca7ec8a4b0f2eb5fa8 (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
37
38
39
40
41
package wordcount

// Source: exercism/x-common
// Commit: 3b07e53 Merge pull request #117 from mikeyjcat/add-raindrops-json

var testCases = []struct {
	description string
	input       string
	output      Frequency
}{
	{
		"count one word",
		"word",
		Frequency{"word": 1},
	},
	{
		"count one of each word",
		"one of each",
		Frequency{"each": 1, "of": 1, "one": 1},
	},
	{
		"multiple occurrences of a word",
		"one fish two fish red fish blue fish",
		Frequency{"blue": 1, "fish": 4, "one": 1, "red": 1, "two": 1},
	},
	{
		"ignore punctuation",
		"car : carpet as java : javascript!!&@$%^&",
		Frequency{"as": 1, "car": 1, "carpet": 1, "java": 1, "javascript": 1},
	},
	{
		"include numbers",
		"testing, 1, 2 testing",
		Frequency{"1": 1, "2": 1, "testing": 2},
	},
	{
		"normalize case",
		"go Go GO",
		Frequency{"go": 3},
	},
}