-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathspec.lua
More file actions
47 lines (42 loc) · 1.16 KB
/
spec.lua
File metadata and controls
47 lines (42 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
describe("distance (implementation)", function()
it("loads module", function()
local f = require 'distance'
end)
it("returns equally distant string", function()
local f = require 'distance'
local middle = f('00', '11')
assert(middle == '01' or middle == '10')
end)
it("returns nil if no equally distant string exists",
function()
local f = require 'distance'
assert(f('0', '1') == nil)
end)
it("throws error if length if input strings differ",
function()
local f = require 'distance'
assert.has_error(function()
f('0', '11')
end)
end)
it("throws error if an argument is not string",
function()
local f = require 'distance'
assert.has_error(function()
f('0', {})
end)
assert.has_error(function()
f({}, '0')
end)
end)
it("throws error if input contains non-0-or-1",
function()
local f = require 'distance'
assert.has_error(function()
f('00', 'aa')
end)
assert.has_error(function()
f('aa', '00')
end)
end)
end)