go-by-test/counter/counter_test.go
2024-09-21 17:51:58 +02:00

21 lines
392 B
Go

package counter
import "testing"
func TestCounter(t *testing.T) {
t.Run("incrementing the counter 3 times leaves it at 3", func(t *testing.T) {
counter := Counter{}
counter.Inc()
counter.Inc()
counter.Inc()
assertCounter(t, counter, 3)
})
}
func assertCounter(t testing.TB, got Counter, want int) {
if got.Value() != 3 {
t.Errorf("got %d, want %d", got.Value(), want)
}
}