5 func TestNumOccurences(t *testing.T) {
12 {"\trfd\ta", '\t', 2},
13 {"∆ƒ\tø ® \t\t", '\t', 3},
15 for _, test := range tests {
16 if got := NumOccurences(test.inputStr, test.inputChar); got != test.want {
17 t.Errorf("NumOccurences(%s, %c) = %d", test.inputStr, test.inputChar, got)
22 func TestSpaces(t *testing.T) {
23 var tests = []struct {
30 for _, test := range tests {
31 if got := Spaces(test.input); got != test.want {
32 t.Errorf("Spaces(%d) = \"%s\"", test.input, got)
37 func TestIsWordChar(t *testing.T) {
38 if IsWordChar("t") == false {
39 t.Errorf("IsWordChar(t) = false")
41 if IsWordChar("T") == false {
42 t.Errorf("IsWordChar(T) = false")
44 if IsWordChar("5") == false {
45 t.Errorf("IsWordChar(5) = false")
47 if IsWordChar("_") == false {
48 t.Errorf("IsWordChar(_) = false")
50 if IsWordChar("~") == true {
51 t.Errorf("IsWordChar(~) = true")
53 if IsWordChar(" ") == true {
54 t.Errorf("IsWordChar( ) = true")
56 if IsWordChar("ß") == true {
57 t.Errorf("IsWordChar(ß) = true")
59 if IsWordChar(")") == true {
60 t.Errorf("IsWordChar()) = true")
62 if IsWordChar("\n") == true {
63 t.Errorf("IsWordChar(\n)) = true")