Added plan of tests

This commit is contained in:
Alexander Pivkin 2025-12-20 09:59:10 +03:00
parent 4833874324
commit a889e1c7dd
7 changed files with 58 additions and 1 deletions

View File

@ -1,3 +1,3 @@
module main.go
go 1.25.5
go 1.24.5

View File

@ -0,0 +1,12 @@
all: run
build:
go build -o kek
run: test
go run main.go
test:
go test
clean:
rm kek

View File

@ -0,0 +1,3 @@
module main.go
go 1.24.5

View File

@ -0,0 +1,19 @@
package main
import (
"fmt"
)
const iterCycles = 5
func Repeat(char string) string {
var repeated string
for i := 0; i < iterCycles; i++ {
repeated += char
}
return repeated
}
func main() {
fmt.Println(Repeat("kek"))
}

View File

@ -0,0 +1,23 @@
package main
import "testing"
func TestRepeat(t *testing.T) {
got := Repeat("a")
want := "aaaaa"
assertionCheck(t, got, want)
}
func BenchmarkRepeat(b *testing.B) {
for b.Loop() {
Repeat("a")
}
}
func assertionCheck(t testing.TB, got, want string) {
t.Helper()
if got != want {
t.Errorf("got %q want %q", got, want)
}
}