blob: c7222dcacf85c98cd0e170ec112033c5993f08ed (
plain)
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
|
import("core.base.hashset")
function test_hashset(t)
local h = hashset.of(1, 2, 3, 5, 5, 7, 1, 9, 4, 6, 8, 0)
t:require(h:size() == 10)
t:require_not(h:empty())
for item in h:items() do
t:require(h:has(item))
t:require_not(h:has(item + 10))
end
local prev = -1
for item in h:orderitems() do
t:require(item > prev)
prev = item
end
local h2 = h:clone()
t:require(h == h2)
h2:insert(11)
t:require_not(h == h2)
h2:remove(11)
t:require(h == h2)
h2:clear()
t:require(h2:empty())
t:require(h == hashset.from(h:to_array()))
end
|