forked from zbirenbaum/copilot.lua
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_suggestion_util.lua
More file actions
32 lines (27 loc) · 868 Bytes
/
test_suggestion_util.lua
File metadata and controls
32 lines (27 loc) · 868 Bytes
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
local u = require("copilot.suggestion.utils")
local eq = MiniTest.expect.equality
local T = MiniTest.new_set({
hooks = {
pre_once = function() end,
pre_case = function() end,
},
})
T["suggestion_utils()"] = MiniTest.new_set()
T["suggestion_utils()"]["remove common suffix"] = function()
local test_cases = {
{ [[event1 = ("test", ),]], [["test2"),]], [["test2"]] },
-- ^
{ [[event2 = ("test", ""),]], [[test2"),]], [[test2]] },
-- ^
{ [[event3 = ("test", ]], [["test2"),]], [["test2"),]] },
-- ^
{ [[event4 = ("test", ]], "", "" },
{ "", [[("test"),]], [[("test"),]] },
}
for _, case in ipairs(test_cases) do
local str, substr, expected = unpack(case)
local result = u.remove_common_suffix(str, substr)
eq(result, expected)
end
end
return T