Newer
Older
#include "parse-pinyin.h"
#include <glib.h>
#include <glib/gprintf.h>
result = parse_pinyin("liyifeng", 15, PINYIN_FLAGS_NONE);
thispy = (Pinyin *) g_list_nth_data(result, 0);
g_assert_cmpint(thispy->shengmu_i, ==, 10);
g_assert_cmpint(thispy->yunmu_i, ==, 34);
g_assert_cmpint(thispy->length, ==, 2);
thispy = (Pinyin *) g_list_nth_data(result, 1);
g_assert_cmpint(thispy->shengmu_i, ==, 21);
g_assert_cmpint(thispy->yunmu_i, ==, 34);
g_assert_cmpint(thispy->length, ==, 2);
thispy = (Pinyin *) g_list_nth_data(result, 2);
g_assert_cmpint(thispy->shengmu_i, ==, 5);
g_assert_cmpint(thispy->yunmu_i, ==, 32);
g_assert_cmpint(thispy->length, ==, 4);
/**
* print GList of Pinyin.
*/
static void
thispy = (Pinyin *) iter->data;
g_printf("shengmu_i=%i yunmu_i=%i length=%u\n",
thispy->shengmu_i, thispy->yunmu_i, thispy->length);
iter = iter->next;
}
}
static void
result = parse_pinyin("zhey", 15, PINYIN_INCOMPLETE_PINYIN);
print_parse_result(result);
g_assert_cmpint(g_list_length(result), ==, 2);
thispy = (Pinyin *) g_list_nth_data(result, 0);
g_assert_cmpint(thispy->shengmu_i, ==, 23);
g_assert_cmpint(thispy->yunmu_i, ==, 29);
g_assert_cmpint(thispy->length, ==, 3);
thispy = (Pinyin *) g_list_nth_data(result, 1);
g_assert_cmpint(thispy->shengmu_i, ==, 21);
g_assert_cmpint(thispy->yunmu_i, ==, 0);
g_assert_cmpint(thispy->length, ==, 1);
g_test_init(&argc, &argv, NULL);
g_test_add_func("/zero/test_parse_pinyin",
test_parse_pinyin);
g_test_add_func("/zero/test_parse_pinyin incomplete pinyin",
test_parse_pinyin_incomplete_pinyin);