Mastering-Go-Second-Edition/ch11/testMe_test.go
Mihalis Tsoukalos d5e43988f7 Minor change
2019-11-07 19:48:47 +02:00

59 lines
745 B
Go

package testMe
import "testing"
func TestS1(t *testing.T) {
if s1("123456789") != 9 {
t.Error(`s1("123456789") != 9`)
}
if s1("") != 0 {
t.Error(`s1("") != 0`)
}
}
func TestS2(t *testing.T) {
if s2("123456789") != 9 {
t.Error(`s2("123456789") != 9`)
}
if s2("") != 0 {
t.Error(`s2("") != 0`)
}
}
func TestF1(t *testing.T) {
if f1(0) != 0 {
t.Error(`f1(0) != 0`)
}
if f1(1) != 1 {
t.Error(`f1(1) != 1`)
}
if f1(2) != 1 {
t.Error(`f1(2) != 1`)
}
if f1(10) != 55 {
t.Error(`f1(10) != 55`)
}
}
func TestF2(t *testing.T) {
if f2(0) != 0 {
t.Error(`f2(0) != 0`)
}
if f2(1) != 1 {
t.Error(`f2(1) != 1`)
}
if f2(2) != 1 {
t.Error(`f2(2) != 1`)
}
if f2(10) != 55 {
t.Error(`f2(10) != 55`)
}
}