Skip to content

Commit 4cc6b6e

Browse files
committed
Add tests for Trie
1 parent bc0b509 commit 4cc6b6e

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

tests/core/test_util.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
1-
from coagent.core.util import get_func_args
1+
from coagent.core.util import Trie, get_func_args
22

33

4-
def func(a: int, b: str, c: float) -> None:
5-
pass
4+
class TestTrie:
5+
def test_direct_items(self):
6+
trie = Trie(separator=".")
7+
trie["test"] = 1
8+
trie["test.a"] = 2
9+
trie["test.b"] = 3
10+
trie["test.a.b"] = 4
11+
trie["test.a.b.c"] = 5
12+
13+
assert trie.direct_items("test") == [("test", 1), ("test.a", 2), ("test.b", 3)]
14+
assert trie.direct_items("test.a") == [("test.a", 2), ("test.a.b", 4)]
15+
assert trie.direct_items("test.a.b") == [("test.a.b", 4), ("test.a.b.c", 5)]
16+
assert trie.direct_items("test.a.b.c") == [("test.a.b.c", 5)]
617

718

819
def test_get_func_args():
20+
def func(a: int, b: str, c: float) -> None:
21+
pass
22+
923
assert get_func_args(func) == {"a", "b", "c"}

0 commit comments

Comments
 (0)