Sha256: d17b9ffda917eecc5e82604b85c0af734e7250a644dc2ff4f8c570edab9c4aa2

Contents?: true

Size: 1.38 KB

Versions: 107

Compression:

Stored size: 1.38 KB

Contents

local valid = require('isbn-verifier').valid

describe('isbn-verifier', function()
  it('valid isbn number', function()
    assert.is_true(valid('3-598-21508-8'))
  end)

  it('invalid isbn check digit', function()
    assert.is_false(valid('3-598-21508-9'))
  end)

  it('valid isbn number with a check digit of 10', function()
    assert.is_true(valid('3-598-21507-X'))
  end)

  it('check digit is a character other than X', function()
    assert.is_false(valid('3-598-21507-A'))
  end)

  it('invalid character in isbn', function()
    assert.is_false(valid('3-598-2K507-0'))
  end)

  it('X is only valid as a check digit', function()
    assert.is_false(valid('3-598-2X507-9'))
  end)

  it('valid isbn without separating dashes', function()
    assert.is_true(valid('3598215088'))
  end)

  it('isbn without separating dashes and X as check digit', function()
    assert.is_true(valid('359821507X'))
  end)

  it('isbn without check digit and dashes', function()
    assert.is_false(valid('359821507'))
  end)

  it('too long isbn and no dashes', function()
    assert.is_false(valid('3598215078X'))
  end)

  it('isbn without check digit', function()
    assert.is_false(valid('3-598-21507'))
  end)

  it('too long isbn', function()
    assert.is_false(valid('3-598-21507-XX'))
  end)

  it('check digit of X should not be used for 0', function()
    assert.is_false(valid('3-598-21515-X'))
  end)
end)

Version data entries

107 entries across 107 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/lua/exercises/isbn-verifier/isbn-verifier_spec.lua
trackler-2.2.1.179 tracks/lua/exercises/isbn-verifier/isbn-verifier_spec.lua
trackler-2.2.1.178 tracks/lua/exercises/isbn-verifier/isbn-verifier_spec.lua
trackler-2.2.1.177 tracks/lua/exercises/isbn-verifier/isbn-verifier_spec.lua
trackler-2.2.1.176 tracks/lua/exercises/isbn-verifier/isbn-verifier_spec.lua
trackler-2.2.1.175 tracks/lua/exercises/isbn-verifier/isbn-verifier_spec.lua
trackler-2.2.1.174 tracks/lua/exercises/isbn-verifier/isbn-verifier_spec.lua
trackler-2.2.1.173 tracks/lua/exercises/isbn-verifier/isbn-verifier_spec.lua
trackler-2.2.1.172 tracks/lua/exercises/isbn-verifier/isbn-verifier_spec.lua
trackler-2.2.1.171 tracks/lua/exercises/isbn-verifier/isbn-verifier_spec.lua
trackler-2.2.1.170 tracks/lua/exercises/isbn-verifier/isbn-verifier_spec.lua
trackler-2.2.1.169 tracks/lua/exercises/isbn-verifier/isbn-verifier_spec.lua
trackler-2.2.1.167 tracks/lua/exercises/isbn-verifier/isbn-verifier_spec.lua
trackler-2.2.1.166 tracks/lua/exercises/isbn-verifier/isbn-verifier_spec.lua
trackler-2.2.1.165 tracks/lua/exercises/isbn-verifier/isbn-verifier_spec.lua
trackler-2.2.1.164 tracks/lua/exercises/isbn-verifier/isbn-verifier_spec.lua
trackler-2.2.1.163 tracks/lua/exercises/isbn-verifier/isbn-verifier_spec.lua
trackler-2.2.1.162 tracks/lua/exercises/isbn-verifier/isbn-verifier_spec.lua
trackler-2.2.1.161 tracks/lua/exercises/isbn-verifier/isbn-verifier_spec.lua
trackler-2.2.1.160 tracks/lua/exercises/isbn-verifier/isbn-verifier_spec.lua