Skip to content

Commit

Permalink
Merge pull request #576 from ricemery/luhn
Browse files Browse the repository at this point in the history
Update luhn to latest canoncial json. Refs #488
  • Loading branch information
ErikSchierboom authored Jul 23, 2018
2 parents b23b9e0 + 3aa153c commit e8df4bb
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions exercises/luhn/src/test/scala/LuhnTest.scala
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)
}
}

0 comments on commit e8df4bb

Please sign in to comment.