add log and unittest

This commit is contained in:
yanyiwu 2016-04-18 14:55:42 +08:00
parent 63e9c94fb7
commit 29e085904d
2 changed files with 18 additions and 1 deletions

View File

@ -18,7 +18,7 @@ class PreFilter {
const string& sentence) const string& sentence)
: symbols_(symbols) { : symbols_(symbols) {
if (!DecodeRunesInString(sentence, sentence_)) { if (!DecodeRunesInString(sentence, sentence_)) {
XLOG(ERROR) << "decode string: " << sentence << " failed"; XLOG(ERROR) << "decode failed. ";
} }
cursor_ = sentence_.begin(); cursor_ = sentence_.begin();
} }

View File

@ -103,6 +103,23 @@ TEST(MixSegmentTest, TestUserDict) {
segment.Cut("忽如一夜春风来,千树万树梨花开", words); segment.Cut("忽如一夜春风来,千树万树梨花开", words);
res = limonp::Join(words.begin(), words.end(), "/"); res = limonp::Join(words.begin(), words.end(), "/");
ASSERT_EQ("忽如一夜春风来//千树/万树/梨花/开", res); ASSERT_EQ("忽如一夜春风来//千树/万树/梨花/开", res);
// rand input
{
const size_t ITERATION = 16;
const size_t MAX_LEN = 256;
string s;
srand(time(NULL));
for (size_t i = 0; i < ITERATION; i++) {
size_t len = rand() % MAX_LEN;
s.resize(len);
for (size_t j = 0; j < len; j++) {
s[rand() % len] = rand();
}
segment.Cut(s, words);
}
}
} }
TEST(MixSegmentTest, TestMultiUserDict) { TEST(MixSegmentTest, TestMultiUserDict) {