23 lines
337 B
Go
23 lines
337 B
Go
package iteration
|
|
|
|
import "testing"
|
|
|
|
func TestRepeat(t *testing.T) {
|
|
got := Repeat("a")
|
|
want := "aaaaa"
|
|
assertResult(t, got, want)
|
|
}
|
|
|
|
func assertResult(t testing.TB, got, want string) {
|
|
t.Helper()
|
|
if got != want {
|
|
t.Errorf("got %q want %q", got, want)
|
|
}
|
|
}
|
|
|
|
func BenchmarkRepeat(b *testing.B) {
|
|
for b.Loop() {
|
|
Repeat("a")
|
|
}
|
|
}
|