diff options
author | Alexander Kiryukhin <a.kiryukhin@mail.ru> | 2019-08-30 01:43:12 +0300 |
---|---|---|
committer | Alexander Kiryukhin <a.kiryukhin@mail.ru> | 2019-08-30 01:43:12 +0300 |
commit | 878cb24695b7d39fa9de65a1e164abc84dc67ead (patch) | |
tree | 73946dd08310c2a3b7535297906a4ff5535db756 /verhoeff | |
parent | b0fba45d68c9ec6c2274ebd61b28ca22bb5deff6 (diff) |
Added Damm algorithm
Diffstat (limited to 'verhoeff')
-rw-r--r-- | verhoeff/verhoeff.go | 2 | ||||
-rw-r--r-- | verhoeff/verhoeff_test.go | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/verhoeff/verhoeff.go b/verhoeff/verhoeff.go index 259a7df..1bc5281 100644 --- a/verhoeff/verhoeff.go +++ b/verhoeff/verhoeff.go @@ -33,7 +33,7 @@ var p = [8][10]int{ var inv = [10]int{0, 4, 3, 2, 1, 5, 6, 7, 8, 9} -// Check number is correct by luhn algorithm +// Check number is correct by verhoeff algorithm func Check(number string) error { c := 0 numbers := strings.Split(number, "") diff --git a/verhoeff/verhoeff_test.go b/verhoeff/verhoeff_test.go index 7678b1f..005caf0 100644 --- a/verhoeff/verhoeff_test.go +++ b/verhoeff/verhoeff_test.go @@ -18,7 +18,7 @@ func TestVerhoeff(t *testing.T) { } for num, result := range samples { if err := Check(num); err != result { - t.Errorf("Expected %+v actual %+v", result, err) + t.Errorf("Expected %+v actual %+v for %s", result, err, num) } } @@ -29,6 +29,6 @@ func TestVerhoeff(t *testing.T) { } numberWithChecksum := num + checksum if err := Check(numberWithChecksum); err != nil { - t.Errorf("Expected no error actual %+v", err) + t.Errorf("Expected no error actual %+v for %s", err, numberWithChecksum) } } |