mirror of
https://github.com/Hopiu/micro.git
synced 2026-04-01 22:00:32 +00:00
35 lines
687 B
Go
35 lines
687 B
Go
package main
|
|
|
|
import "testing"
|
|
|
|
func TestNumOccurences(t *testing.T) {
|
|
var tests = []struct {
|
|
inputStr string
|
|
inputChar byte
|
|
want int
|
|
}{
|
|
{"aaaa", 'a', 4},
|
|
{"\trfd\ta", '\t', 2},
|
|
{"∆ƒ\tø ® \t\t", '\t', 3},
|
|
}
|
|
for _, test := range tests {
|
|
if got := NumOccurences(test.inputStr, test.inputChar); got != test.want {
|
|
t.Errorf("NumOccurences(%s, %c) = %d", test.inputStr, test.inputChar, got)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestSpaces(t *testing.T) {
|
|
var tests = []struct {
|
|
input int
|
|
want string
|
|
}{
|
|
{4, " "},
|
|
{0, ""},
|
|
}
|
|
for _, test := range tests {
|
|
if got := Spaces(test.input); got != test.want {
|
|
t.Errorf("Spaces(%d) = \"%s\"", test.input, got)
|
|
}
|
|
}
|
|
}
|