From 878cb24695b7d39fa9de65a1e164abc84dc67ead Mon Sep 17 00:00:00 2001 From: Alexander Kiryukhin Date: Fri, 30 Aug 2019 01:43:12 +0300 Subject: Added Damm algorithm --- verhoeff/verhoeff.go | 2 +- verhoeff/verhoeff_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'verhoeff') 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) } } -- cgit v1.2.3