Skip to content

[bug]Whether QueryByPrefix does not conform to the api definition? #2

@songzhibin97

Description

@songzhibin97
func TestTrie_FindByPrefix(t *testing.T) {
	trie := New[string]()
	_ = trie.Upsert("china", "china")
	_ = trie.Upsert("chinese", "chinese")
	_ = trie.Upsert("channel", "channel")
	_ = trie.Upsert("chan", "chan")
	_ = trie.Upsert("boy", "boy")
	_ = trie.Upsert("cc11001100", "CC11001100")

	slice := trie.QueryByPrefix("c") // len(slice) is 0
	//t.Log(slice)
	assert.Equal(t, 5, len(slice))
}

QueryByPrefix 根据前缀查询单词, 如果不是一个具体的单词会直接返回错误,不符合api定义的预期

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions