aboutsummaryrefslogtreecommitdiff
path: root/luhn/luhn_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'luhn/luhn_test.go')
-rw-r--r--luhn/luhn_test.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/luhn/luhn_test.go b/luhn/luhn_test.go
new file mode 100644
index 0000000..ea36119
--- /dev/null
+++ b/luhn/luhn_test.go
@@ -0,0 +1,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)
+ }
+ }
+}