aboutsummaryrefslogtreecommitdiff
path: root/luhn/luhn_test.go
blob: ea361190ed1d6f52594dbd0dcca49afb9b94cdea (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", result, err)
		}
	}
}