From 0a4f44ab15b9bdc6a651affafa14589259efdfd5 Mon Sep 17 00:00:00 2001 From: Gibson Fahnestock Date: Mon, 30 Jan 2017 08:26:20 +0000 Subject: [PATCH] luhn: Add more tests The luhn test suite didn't cover a lot of cases, including: - Strings of zeros - Non-alphabetic characters - Numbers which are only valid if you reverse the string --- exercises/luhn/canonical-data.json | 35 ++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/exercises/luhn/canonical-data.json b/exercises/luhn/canonical-data.json index 0da43846c0..95bd2ffafd 100644 --- a/exercises/luhn/canonical-data.json +++ b/exercises/luhn/canonical-data.json @@ -10,6 +10,11 @@ "input": "0", "expected": false }, + { + "description": "simple valid sin", + "input": " 5 9 ", + "expected": true + }, { "description": "valid Canadian SIN", "input": "046 454 286", @@ -29,6 +34,36 @@ "description": "valid strings with a non-digit added become invalid", "input": "046a 454 286", "expected": false + }, + { + "description": "punctuation is not allowed", + "input": "055-444-285", + "expected": false + }, + { + "description": "symbols are not allowed", + "input": "055£ 444$ 285", + "expected": false + }, + { + "description": "single zero with space is invalid", + "input": " 0", + "expected": false + }, + { + "description": "lots of zeros are valid", + "input": " 00000", + "expected": true + }, + { + "description": "another valid sin", + "input": "055 444 285", + "expected": true + }, + { + "description": "nine doubled is nine", + "input": "091", + "expected": true } ] }