From 5b487bd6d66f9a8f43260a9bec978ea8cf692995 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Wed, 11 May 2016 16:38:14 +0800 Subject: fixes compile --- src/storage/phonetic_key_matrix.h | 15 +++++++++++++-- tests/storage/Makefile.am | 9 ++++++--- tests/storage/test_matrix.cpp | 3 ++- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/storage/phonetic_key_matrix.h b/src/storage/phonetic_key_matrix.h index 8ad885b..99aeb11 100644 --- a/src/storage/phonetic_key_matrix.h +++ b/src/storage/phonetic_key_matrix.h @@ -35,6 +35,17 @@ protected: GPtrArray * m_table_content; public: + PhoneticTable() { + m_table_content = g_ptr_array_new(); + } + + ~PhoneticTable() { + clear_all(); + + g_ptr_array_free(m_table_content, TRUE); + m_table_content = NULL; + } + bool clear_all() { for (size_t i = 0; i < m_table_content->len; ++i) { GArray * column = (GArray *) @@ -46,7 +57,7 @@ public: return true; } - bool size() { + size_t size() { return m_table_content->len; } @@ -99,7 +110,7 @@ public: return m_keys.clear_all() && m_key_rests.clear_all(); } - bool size() { + size_t size() { assert(m_keys.size() == m_key_rests.size()); return m_keys.size(); } diff --git a/tests/storage/Makefile.am b/tests/storage/Makefile.am index 7675d11..1f74e72 100644 --- a/tests/storage/Makefile.am +++ b/tests/storage/Makefile.am @@ -34,6 +34,7 @@ noinst_PROGRAMS = test_phrase_index \ test_ngram \ test_flexible_ngram \ test_parser2 \ + test_matrix \ test_chewing_table \ test_table_info @@ -44,11 +45,13 @@ test_phrase_index_logger_SOURCES = test_phrase_index_logger.cpp test_phrase_table_SOURCES = test_phrase_table.cpp -test_ngram_SOURCES = test_ngram.cpp +test_ngram_SOURCES = test_ngram.cpp -test_flexible_ngram_SOURCES = test_flexible_ngram.cpp +test_flexible_ngram_SOURCES = test_flexible_ngram.cpp -test_parser2_SOURCES = test_parser2.cpp +test_parser2_SOURCES = test_parser2.cpp + +test_matrix_SOURCES = test_matrix.cpp test_chewing_table_SOURCES = test_chewing_table.cpp diff --git a/tests/storage/test_matrix.cpp b/tests/storage/test_matrix.cpp index ba9b3e0..fd965b8 100644 --- a/tests/storage/test_matrix.cpp +++ b/tests/storage/test_matrix.cpp @@ -23,6 +23,7 @@ #include #include "pinyin_internal.h" +size_t bench_times = 1000; using namespace pinyin; @@ -30,7 +31,7 @@ int main(int argc, char * argv[]) { pinyin_option_t options = PINYIN_CORRECT_ALL; options |= PINYIN_INCOMPLETE; - PhoneticParser2 * parser = FullPinyinParser2(); + PhoneticParser2 * parser = new FullPinyinParser2(); ChewingKeyVector keys = g_array_new(FALSE, FALSE, sizeof(ChewingKey)); ChewingKeyRestVector key_rests = g_array_new(FALSE, FALSE, sizeof(ChewingKeyRest)); -- cgit