Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions exercises/luhn/canonical-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can I get a confirmation on whether the £ is in ASCII? I am seeing bytes 0xc2 0xa3 for it

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not.

"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",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you confirm - what does this test that above cases do not? is it just here to contrast with 055-444-285? What is an example of an implementation that would pass the above cases but fail this one?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Part of it was the contrast with 0555-444-285, and part of it was the thought that having a couple of different longer valid numbers might help someone who was struggling to work out how the algorithm needed to be implemented.

I can remove it if necessary.

"expected": true
},
{
"description": "nine doubled is nine",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in case anyone wonder, this caught a bug in mine (I was using mod 9 after doubling, which turns nine into zero instead of nine)

"input": "091",
"expected": true
}
]
}