2020-01-01 22:02:44 +01:00
|
|
|
#include "test.h"
|
2020-01-01 17:15:07 +01:00
|
|
|
#include "translit.h"
|
|
|
|
#include "../transliteration.h"
|
|
|
|
|
2020-01-07 13:18:54 +01:00
|
|
|
static void test_transliterate_devanagari_to_latin(const char *devanagari,
|
|
|
|
const char *latin)
|
2020-01-01 17:15:07 +01:00
|
|
|
{
|
2020-01-07 13:18:54 +01:00
|
|
|
char *str = transliterate_devanagari_to_latin(devanagari);
|
|
|
|
ck_assert_str_eq(latin, str);
|
|
|
|
free(str);
|
|
|
|
}
|
2020-01-01 17:15:07 +01:00
|
|
|
|
2020-01-07 13:18:54 +01:00
|
|
|
static void test_transliterate_latin_to_devanagari(const char *latin,
|
|
|
|
const char *devanagari)
|
|
|
|
{
|
|
|
|
char *str = transliterate_latin_to_devanagari(latin);
|
|
|
|
ck_assert_str_eq(devanagari, str);
|
|
|
|
free(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
START_TEST(test_translit_devanagari_to_latin)
|
|
|
|
{
|
2020-01-01 17:15:07 +01:00
|
|
|
/* https://en.wikipedia.org/wiki/Sanskrit */
|
2020-01-07 13:18:54 +01:00
|
|
|
test_transliterate_devanagari_to_latin("संस्कृतम्", "saṃskṛtam");
|
2020-01-01 17:15:07 +01:00
|
|
|
|
|
|
|
/* https://en.wikipedia.org/wiki/Bhagavad_Gita */
|
2020-01-07 13:18:54 +01:00
|
|
|
test_transliterate_devanagari_to_latin("भगवद्गीता", "bhagavadgītā");
|
2020-01-01 17:15:07 +01:00
|
|
|
|
|
|
|
/* https://en.wikipedia.org/wiki/%C4%80ry%C4%81varta */
|
2020-01-07 13:18:54 +01:00
|
|
|
test_transliterate_devanagari_to_latin("आर्यावर्त", "āryāvarta");
|
2020-01-01 17:15:07 +01:00
|
|
|
|
|
|
|
/* https://en.wikipedia.org/wiki/Mahabharata */
|
2020-01-07 13:18:54 +01:00
|
|
|
test_transliterate_devanagari_to_latin("महाभारतम्", "mahābhāratam");
|
|
|
|
|
|
|
|
/* https://en.wikipedia.org/wiki/Devanagari */
|
|
|
|
test_transliterate_devanagari_to_latin("देवनागरी", "devanāgarī");
|
|
|
|
|
2020-01-01 17:15:07 +01:00
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2020-01-01 22:02:44 +01:00
|
|
|
START_TEST(test_translit_latin_to_devanagari)
|
|
|
|
{
|
2020-01-07 13:18:54 +01:00
|
|
|
test_transliterate_latin_to_devanagari("saṃskṛtam", "संस्कृतम्");
|
|
|
|
test_transliterate_latin_to_devanagari("bhagavadgītā", "भगवद्गीता");
|
|
|
|
test_transliterate_latin_to_devanagari("āryāvarta", "आर्यावर्त");
|
|
|
|
test_transliterate_latin_to_devanagari("mahābhāratam", "महाभारतम्");
|
|
|
|
test_transliterate_latin_to_devanagari("devanāgarī", "देवनागरी");
|
2020-01-01 22:02:44 +01:00
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2020-10-11 08:55:24 +02:00
|
|
|
START_TEST(test_translit_lla_sylable)
|
|
|
|
{
|
|
|
|
test_transliterate_devanagari_to_latin("अग्निमीळे", "agnimīḷe");
|
|
|
|
test_transliterate_latin_to_devanagari("agnimīḷe", "अग्निमीळे");
|
|
|
|
|
|
|
|
test_transliterate_devanagari_to_latin("चाकॢप्र", "cākḷpra");
|
|
|
|
test_transliterate_latin_to_devanagari("cākḷpra", "चाकॢप्र");
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2020-01-01 17:15:07 +01:00
|
|
|
void register_translit_tests(TCase *test_case)
|
|
|
|
{
|
|
|
|
tcase_add_test(test_case, test_translit_devanagari_to_latin);
|
2020-01-01 22:02:44 +01:00
|
|
|
tcase_add_test(test_case, test_translit_latin_to_devanagari);
|
2020-10-11 08:55:24 +02:00
|
|
|
tcase_add_test(test_case, test_translit_lla_sylable);
|
2020-01-01 17:15:07 +01:00
|
|
|
}
|