exercism/go/isbn-verifier/isbn_verifier_test.go
2022-08-24 14:28:45 +02:00

29 lines
569 B
Go

package isbn
import (
"testing"
)
func TestIsValidISBN(t *testing.T) {
for _, test := range testCases {
observed := IsValidISBN(test.isbn)
if observed == test.expected {
t.Logf("PASS: %s", test.description)
} else {
t.Errorf("FAIL: %s\nIsValidISBN(%q)\nExpected: %t, Actual: %t",
test.description, test.isbn, test.expected, observed)
}
}
}
func BenchmarkIsValidISBN(b *testing.B) {
if testing.Short() {
b.Skip("skipping benchmark in short mode.")
}
for i := 0; i < b.N; i++ {
for _, n := range testCases {
IsValidISBN(n.isbn)
}
}
}