Sha256: a5edd9be28fb2d137d9ab3ee26aec32968b434abbf96f6212bec79e95d93183b

Contents?: true

Size: 1.79 KB

Versions: 95

Compression:

Stored size: 1.79 KB

Contents

#!/usr/bin/env bats

@test "single digit strings cannot be valid" {
  #skip
  run bash luhn.sh "1"

  [ "$status" -eq 0 ]
  [ "$output" == "false" ]
}

@test "a single zero is invalid" {
  #skip
  run bash luhn.sh "0"

  [ "$status" -eq 0 ]
  [ "$output" == "false" ]
}

@test "a simple valid SIN that remains valid if reversed" {
  #skip
  run bash luhn.sh "059"

  [ "$status" -eq 0 ]
  [ "$output" == "true" ]
}

@test "a simple valid SIN that becomes invalid if reversed" {
  #skip
  run bash luhn.sh "59"

  [ "$status" -eq 0 ]
  [ "$output" == "true" ]
}

@test "a valid Canadian SIN" {
  #skip
  run bash luhn.sh "055 444 285"

  [ "$status" -eq 0 ]
  [ "$output" == "true" ]
}

@test "invalid Canadian SID" {
  #skip
  run bash luhn.sh "055 444 286"

  [ "$status" -eq 0 ]
  [ "$output" == "false" ]
}

@test "invalid credit card" {
  #skip
  run bash luhn.sh "8273 1232 7352 0569"

  [ "$status" -eq 0 ]
  [ "$output" == "false" ]
}

@test "valid strings with a non-digit included become invalid" {
  #skip
  run bash luhn.sh "055a 444 285"

  [ "$status" -eq 0 ]
  [ "$output" == "false" ]
}

@test "valid strings with punctuation included become invalid" {
  #skip
  run bash luhn.sh "055-444-285"

  [ "$status" -eq 0 ]
  [ "$output" == "false" ]
}

@test "valid strings with symbols included become invalid" {
  #skip
  run bash luhn.sh "055£ 444$ 285"

  [ "$status" -eq 0 ]
  [ "$output" == "false" ]
}

@test "single zero with space is invalid" {
  #skip
  run bash luhn.sh " 0"

  [ "$status" -eq 0 ]
  [ "$output" == "false" ]
}

@test "more than a single zero is valid" {
  #skip
  run bash luhn.sh "0000 0"

  [ "$status" -eq 0 ]
  [ "$output" == "true" ]
}

@test "input digit 9 is correctly converted to output digit 9" {
  #skip
  run bash luhn.sh "091"

  [ "$status" -eq 0 ]
  [ "$output" == "true" ]
}

Version data entries

95 entries across 95 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/bash/exercises/luhn/luhn_test.sh
trackler-2.2.1.179 tracks/bash/exercises/luhn/luhn_test.sh
trackler-2.2.1.178 tracks/bash/exercises/luhn/luhn_test.sh
trackler-2.2.1.177 tracks/bash/exercises/luhn/luhn_test.sh
trackler-2.2.1.176 tracks/bash/exercises/luhn/luhn_test.sh
trackler-2.2.1.175 tracks/bash/exercises/luhn/luhn_test.sh
trackler-2.2.1.174 tracks/bash/exercises/luhn/luhn_test.sh
trackler-2.2.1.173 tracks/bash/exercises/luhn/luhn_test.sh
trackler-2.2.1.172 tracks/bash/exercises/luhn/luhn_test.sh
trackler-2.2.1.171 tracks/bash/exercises/luhn/luhn_test.sh
trackler-2.2.1.170 tracks/bash/exercises/luhn/luhn_test.sh
trackler-2.2.1.169 tracks/bash/exercises/luhn/luhn_test.sh
trackler-2.2.1.167 tracks/bash/exercises/luhn/luhn_test.sh
trackler-2.2.1.166 tracks/bash/exercises/luhn/luhn_test.sh
trackler-2.2.1.165 tracks/bash/exercises/luhn/luhn_test.sh
trackler-2.2.1.164 tracks/bash/exercises/luhn/luhn_test.sh
trackler-2.2.1.163 tracks/bash/exercises/luhn/luhn_test.sh
trackler-2.2.1.162 tracks/bash/exercises/luhn/luhn_test.sh
trackler-2.2.1.161 tracks/bash/exercises/luhn/luhn_test.sh
trackler-2.2.1.160 tracks/bash/exercises/luhn/luhn_test.sh