7 func TestNumOccurences(t *testing.T) {
14 {"\trfd\ta", '\t', 2},
15 {"∆ƒ\tø ® \t\t", '\t', 3},
17 for _, test := range tests {
18 if got := NumOccurrences(test.inputStr, test.inputChar); got != test.want {
19 t.Errorf("NumOccurences(%s, %c) = %d", test.inputStr, test.inputChar, got)
24 func TestSpaces(t *testing.T) {
25 var tests = []struct {
32 for _, test := range tests {
33 if got := Spaces(test.input); got != test.want {
34 t.Errorf("Spaces(%d) = \"%s\"", test.input, got)
39 func TestIsWordChar(t *testing.T) {
40 if IsWordChar("t") == false {
41 t.Errorf("IsWordChar(t) = false")
43 if IsWordChar("T") == false {
44 t.Errorf("IsWordChar(T) = false")
46 if IsWordChar("5") == false {
47 t.Errorf("IsWordChar(5) = false")
49 if IsWordChar("_") == false {
50 t.Errorf("IsWordChar(_) = false")
52 if IsWordChar("ß") == false {
53 t.Errorf("IsWordChar(ß) = false")
55 if IsWordChar("~") == true {
56 t.Errorf("IsWordChar(~) = true")
58 if IsWordChar(" ") == true {
59 t.Errorf("IsWordChar( ) = true")
61 if IsWordChar(")") == true {
62 t.Errorf("IsWordChar()) = true")
64 if IsWordChar("\n") == true {
65 t.Errorf("IsWordChar(\n)) = true")
69 func TestStringWidth(t *testing.T) {
71 if w := StringWidth("1\t2", tabsize); w != 5 {
72 t.Error("StringWidth 1 Failed. Got", w)
74 if w := StringWidth("\t", tabsize); w != 4 {
75 t.Error("StringWidth 2 Failed. Got", w)
77 if w := StringWidth("1\t", tabsize); w != 4 {
78 t.Error("StringWidth 3 Failed. Got", w)
80 if w := StringWidth("\t\t", tabsize); w != 8 {
81 t.Error("StringWidth 4 Failed. Got", w)
83 if w := StringWidth("12\t2\t", tabsize); w != 8 {
84 t.Error("StringWidth 5 Failed. Got", w)
88 func TestWidthOfLargeRunes(t *testing.T) {
90 if w := WidthOfLargeRunes("1\t2", tabsize); w != 2 {
91 t.Error("WidthOfLargeRunes 1 Failed. Got", w)
93 if w := WidthOfLargeRunes("\t", tabsize); w != 3 {
94 t.Error("WidthOfLargeRunes 2 Failed. Got", w)
96 if w := WidthOfLargeRunes("1\t", tabsize); w != 2 {
97 t.Error("WidthOfLargeRunes 3 Failed. Got", w)
99 if w := WidthOfLargeRunes("\t\t", tabsize); w != 6 {
100 t.Error("WidthOfLargeRunes 4 Failed. Got", w)
102 if w := WidthOfLargeRunes("12\t2\t", tabsize); w != 3 {
103 t.Error("WidthOfLargeRunes 5 Failed. Got", w)