forked from CopilotC-Nvim/CopilotChat.nvim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorderedmap_spec.lua
More file actions
37 lines (33 loc) · 989 Bytes
/
orderedmap_spec.lua
File metadata and controls
37 lines (33 loc) · 989 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
33
34
35
36
37
local orderedmap = require('CopilotChat.utils.orderedmap')
describe('CopilotChat.utils.orderedmap', function()
it('sets and gets values', function()
local map = orderedmap()
map:set('a', 1)
map:set('b', 2)
assert.equals(1, map:get('a'))
assert.equals(2, map:get('b'))
end)
it('preserves insertion order', function()
local map = orderedmap()
map:set('x', 10)
map:set('y', 20)
map:set('z', 30)
assert.are.same({ 'x', 'y', 'z' }, map:keys())
assert.are.same({ 10, 20, 30 }, map:values())
end)
it('overwrites value but not order', function()
local map = orderedmap()
map:set('a', 1)
map:set('a', 2)
assert.are.same({ 'a' }, map:keys())
assert.are.same({ 2 }, map:values())
end)
it('removes values and updates order', function()
local map = orderedmap()
map:set('a', 1)
map:set('b', 2)
map:remove('a')
assert.are.same({ 'b' }, map:keys())
assert.are.same({ 2 }, map:values())
end)
end)