mirror of
https://github.com/yanyiwu/cppjieba.git
synced 2025-07-18 00:00:12 +08:00
fix potential bug in Trie.hpp
This commit is contained in:
parent
61f542a6b1
commit
c04ab76afb
@ -71,13 +71,16 @@ namespace CppJieba
|
||||
}
|
||||
Trie(const string& filePath)
|
||||
{
|
||||
Trie();
|
||||
new (this) Trie();
|
||||
_setInitFlag(init(filePath));
|
||||
}
|
||||
~Trie()
|
||||
{
|
||||
_deleteNode(_root);
|
||||
}
|
||||
private:
|
||||
|
||||
|
||||
public:
|
||||
bool init(const string& filePath)
|
||||
{
|
||||
|
@ -5,8 +5,18 @@ using namespace CppJieba;
|
||||
|
||||
static const char* const DICT_FILE = "../dict/extra_dict/jieba.dict.small.utf8";
|
||||
|
||||
TEST(TrieTest, NewAndDelete)
|
||||
{
|
||||
Trie * trie;
|
||||
trie = new Trie(DICT_FILE);
|
||||
delete trie;
|
||||
trie = new Trie();
|
||||
delete trie;
|
||||
}
|
||||
|
||||
TEST(TrieTest, Test1)
|
||||
{
|
||||
|
||||
string s1, s2;
|
||||
Trie trie;
|
||||
ASSERT_TRUE(trie.init(DICT_FILE));
|
||||
|
Loading…
x
Reference in New Issue
Block a user