summaryrefslogtreecommitdiffstats
path: root/tests/storage/test_chewing_table.cpp
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2012-05-18 11:13:13 +0800
committerPeng Wu <alexepico@gmail.com>2012-05-18 11:21:23 +0800
commit46d7e4c0e4a1a0a8b8e8b8346e88d222597dacb7 (patch)
tree28ff718d1172b7a4d150fd3c2f8d4fb87353fdc2 /tests/storage/test_chewing_table.cpp
parent54b8d345cb1c5f527a58457e6619004f5ecf4fb0 (diff)
downloadlibpinyin-46d7e4c0e4a1a0a8b8e8b8346e88d222597dacb7.zip
libpinyin-46d7e4c0e4a1a0a8b8e8b8346e88d222597dacb7.tar.gz
libpinyin-46d7e4c0e4a1a0a8b8e8b8346e88d222597dacb7.tar.xz
fixes test_chewing_table
Diffstat (limited to 'tests/storage/test_chewing_table.cpp')
-rw-r--r--tests/storage/test_chewing_table.cpp75
1 files changed, 38 insertions, 37 deletions
diff --git a/tests/storage/test_chewing_table.cpp b/tests/storage/test_chewing_table.cpp
index a5d5bea..1c705f1 100644
--- a/tests/storage/test_chewing_table.cpp
+++ b/tests/storage/test_chewing_table.cpp
@@ -92,46 +92,47 @@ int main(int argc, char * argv[]) {
for (size_t i = 0; i < PHRASE_INDEX_LIBRARY_COUNT; ++i) {
GArray * & range = ranges[i];
- if (range) {
- if (range->len)
- printf("range items number:%d\n", range->len);
-
- for (size_t k = 0; k < range->len; ++k) {
- PhraseIndexRange * onerange =
- &g_array_index(range, PhraseIndexRange, k);
- printf("start:%d\tend:%d\n", onerange->m_range_begin,
- onerange->m_range_end);
-
- PhraseItem item;
- for ( phrase_token_t token = onerange->m_range_begin;
- token != onerange->m_range_end; ++token){
-
- phrase_index.get_phrase_item( token, item);
-
- /* get phrase string */
- ucs4_t buffer[MAX_PHRASE_LENGTH + 1];
- item.get_phrase_string(buffer);
- char * string = g_ucs4_to_utf8
- ( buffer, item.get_phrase_length(),
- NULL, NULL, NULL);
- printf("%s\t", string);
- g_free(string);
-
- ChewingKey chewing_buffer[MAX_PHRASE_LENGTH];
- size_t npron = item.get_n_pronunciation();
- guint32 freq;
- for (size_t m = 0; m < npron; ++m){
- item.get_nth_pronunciation(m, chewing_buffer, freq);
- for (size_t n = 0; n < item.get_phrase_length();
- ++n){
- printf("%s'",
- chewing_buffer[n].get_pinyin_string());
- }
- printf("\b\t%d\t", freq);
+ if (!range)
+ continue;
+
+ if (range->len)
+ printf("range items number:%d\n", range->len);
+
+ for (size_t k = 0; k < range->len; ++k) {
+ PhraseIndexRange * onerange =
+ &g_array_index(range, PhraseIndexRange, k);
+ printf("start:%d\tend:%d\n", onerange->m_range_begin,
+ onerange->m_range_end);
+
+ PhraseItem item;
+ for ( phrase_token_t token = onerange->m_range_begin;
+ token != onerange->m_range_end; ++token){
+
+ phrase_index.get_phrase_item( token, item);
+
+ /* get phrase string */
+ ucs4_t buffer[MAX_PHRASE_LENGTH + 1];
+ item.get_phrase_string(buffer);
+ char * string = g_ucs4_to_utf8
+ ( buffer, item.get_phrase_length(),
+ NULL, NULL, NULL);
+ printf("%s\t", string);
+ g_free(string);
+
+ ChewingKey chewing_buffer[MAX_PHRASE_LENGTH];
+ size_t npron = item.get_n_pronunciation();
+ guint32 freq;
+ for (size_t m = 0; m < npron; ++m){
+ item.get_nth_pronunciation(m, chewing_buffer, freq);
+ for (size_t n = 0; n < item.get_phrase_length();
+ ++n){
+ printf("%s'",
+ chewing_buffer[n].get_pinyin_string());
}
+ printf("\b\t%d\t", freq);
}
- printf("\n");
}
+ printf("\n");
}
g_array_set_size(range, 0);
}