-
-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #576 from ricemery/luhn
Update luhn to latest canoncial json. Refs #488
- Loading branch information
Showing
1 changed file
with
19 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,74 @@ | ||
import org.scalatest.{Matchers, FunSuite} | ||
|
||
/** @version 1.1.0 */ | ||
/** @version 1.2.0 */ | ||
class LuhnTest extends FunSuite with Matchers { | ||
|
||
test("single digit strings can not be valid") { | ||
Luhn.valid("1") should be (false) | ||
Luhn.valid("1") should be(false) | ||
} | ||
|
||
test("a single zero is invalid") { | ||
pending | ||
Luhn.valid("0") should be (false) | ||
Luhn.valid("0") should be(false) | ||
} | ||
|
||
test("a simple valid SIN that remains valid if reversed") { | ||
pending | ||
Luhn.valid("059") should be (true) | ||
Luhn.valid("059") should be(true) | ||
} | ||
|
||
test("a simple valid SIN that becomes invalid if reversed") { | ||
pending | ||
Luhn.valid("59") should be (true) | ||
Luhn.valid("59") should be(true) | ||
} | ||
|
||
test("a valid Canadian SIN") { | ||
pending | ||
Luhn.valid("055 444 285") should be (true) | ||
Luhn.valid("055 444 285") should be(true) | ||
} | ||
|
||
test("invalid Canadian SIN") { | ||
pending | ||
Luhn.valid("055 444 286") should be (false) | ||
Luhn.valid("055 444 286") should be(false) | ||
} | ||
|
||
test("invalid credit card") { | ||
pending | ||
Luhn.valid("8273 1232 7352 0569") should be (false) | ||
Luhn.valid("8273 1232 7352 0569") should be(false) | ||
} | ||
|
||
test("valid strings with a non-digit included become invalid") { | ||
pending | ||
Luhn.valid("055a 444 285") should be (false) | ||
Luhn.valid("055a 444 285") should be(false) | ||
} | ||
|
||
test("valid strings with punctuation included become invalid") { | ||
pending | ||
Luhn.valid("055-444-285") should be (false) | ||
Luhn.valid("055-444-285") should be(false) | ||
} | ||
|
||
test("valid strings with symbols included become invalid") { | ||
pending | ||
Luhn.valid("055£ 444$ 285") should be (false) | ||
Luhn.valid("055£ 444$ 285") should be(false) | ||
} | ||
|
||
test("single zero with space is invalid") { | ||
pending | ||
Luhn.valid(" 0") should be (false) | ||
Luhn.valid(" 0") should be(false) | ||
} | ||
|
||
test("more than a single zero is valid") { | ||
pending | ||
Luhn.valid("0000 0") should be (true) | ||
Luhn.valid("0000 0") should be(true) | ||
} | ||
|
||
test("input digit 9 is correctly converted to output digit 9") { | ||
pending | ||
Luhn.valid("091") should be (true) | ||
Luhn.valid("091") should be(true) | ||
} | ||
|
||
test("strings with non-digits is invalid") { | ||
pending | ||
Luhn.valid(":9") should be(false) | ||
} | ||
} |