diff options
| author | ruki <[email protected]> | 2024-10-06 23:09:48 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-10-06 23:10:23 +0800 |
| commit | d329532d12907f2f27f7c336ab0498700931317a (patch) | |
| tree | 41e78734781742b345387d002991351de21ad4d7 /tests/modules/hashset/test.lua | |
| parent | 6c973f55a3130fe62342e4ab06e992eac6ee3a80 (diff) | |
improve hashset
Diffstat (limited to 'tests/modules/hashset/test.lua')
| -rw-r--r-- | tests/modules/hashset/test.lua | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/modules/hashset/test.lua b/tests/modules/hashset/test.lua new file mode 100644 index 000000000..a0df5a61d --- /dev/null +++ b/tests/modules/hashset/test.lua @@ -0,0 +1,17 @@ +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 +end + |
