Added plan of tests
This commit is contained in:
parent
4833874324
commit
a889e1c7dd
|
|
@ -1,3 +1,3 @@
|
|||
module main.go
|
||||
|
||||
go 1.25.5
|
||||
go 1.24.5
|
||||
12
testing/iterations/Makefile
Normal file
12
testing/iterations/Makefile
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
all: run
|
||||
|
||||
build:
|
||||
go build -o kek
|
||||
|
||||
run: test
|
||||
go run main.go
|
||||
test:
|
||||
go test
|
||||
|
||||
clean:
|
||||
rm kek
|
||||
3
testing/iterations/go.mod
Normal file
3
testing/iterations/go.mod
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
module main.go
|
||||
|
||||
go 1.24.5
|
||||
19
testing/iterations/main.go
Normal file
19
testing/iterations/main.go
Normal 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"))
|
||||
}
|
||||
23
testing/iterations/repeated_test.go
Normal file
23
testing/iterations/repeated_test.go
Normal 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)
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user