Skip to content
parse-pinyin-test.cpp 925 B
Newer Older
Yuanle Song's avatar
Yuanle Song committed
#include "parse-pinyin.hpp"
#include <iostream>
#include <glib.h>

static void
test_parse_pinyin ()
{
	std::vector<Pinyin*>* result = parse_pinyin ("liyifeng");
	g_assert_cmpint (result->size (), ==, 3);

	g_assert_cmpint (result->at(0)->shengmu_i, ==, 10);
	g_assert_cmpint (result->at(0)->yunmu_i, ==, 34);
	g_assert_cmpint (result->at(0)->length, ==, 2);

	g_assert_cmpint (result->at(1)->shengmu_i, ==, 21);
	g_assert_cmpint (result->at(1)->yunmu_i, ==, 34);
	g_assert_cmpint (result->at(1)->length, ==, 2);

	g_assert_cmpint (result->at(2)->shengmu_i, ==, 5);
	g_assert_cmpint (result->at(2)->yunmu_i, ==, 32);
	g_assert_cmpint (result->at(2)->length, ==, 4);

	for (guint i = 0; i < result->size (); ++i) {
		delete result->at(i);
	}
	delete result;
}

int
main (int argc, char *argv[])
{
	g_test_init (&argc, &argv, NULL);
	g_test_add_func ("/zero/test_parse_pinyin",
			 test_parse_pinyin);

	return g_test_run ();
}