blob: 24e57f20fb58936ee538422b33202423e81c589c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
package luhn
import (
"testing"
"github.com/neonxp/checksum"
)
func TestLuhn(t *testing.T) {
samples := map[string]error{
"4561261212345464": checksum.ErrInvalidChecksum,
"A561261212345464": checksum.ErrInvalidNumber,
"4561261212345467": nil,
}
for num, result := range samples {
if err := Check(num); err != result {
t.Errorf("Expected %+v actual %+v for %s", result, err, num)
}
}
}
|