2020-10-16 09:00:05 +02:00
|
|
|
#include "test.h"
|
|
|
|
#include "velthuis.h"
|
|
|
|
#include "../velthuis.h"
|
|
|
|
|
2021-12-28 21:23:49 +01:00
|
|
|
#define ZWJ "\u200d"
|
|
|
|
#define ZWNJ "\u200c"
|
|
|
|
|
|
|
|
static void test_velthuis(const char *velthuis, const char *iast)
|
2020-10-16 09:00:05 +02:00
|
|
|
{
|
2021-12-28 21:23:49 +01:00
|
|
|
char *a, *b;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = encode_velthuis_to_iast(velthuis, &a);
|
|
|
|
ck_assert_int_eq(0, ret);
|
|
|
|
ck_assert_str_eq(iast, a);
|
2021-04-16 10:03:08 +02:00
|
|
|
|
2021-12-28 21:23:49 +01:00
|
|
|
ret = encode_iast_to_velthuis(a, &b);
|
|
|
|
ck_assert_int_eq(0, ret);
|
|
|
|
ck_assert_str_eq(velthuis, b);
|
|
|
|
|
|
|
|
free(a);
|
|
|
|
free(b);
|
2020-10-16 09:00:05 +02:00
|
|
|
}
|
|
|
|
|
2021-12-28 21:23:49 +01:00
|
|
|
static void test_velthuis_oneway(const char *velthuis, const char *iast)
|
2020-10-16 09:00:05 +02:00
|
|
|
{
|
2021-12-28 21:23:49 +01:00
|
|
|
char *str;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = encode_velthuis_to_iast(velthuis, &str);
|
|
|
|
ck_assert_int_eq(0, ret);
|
|
|
|
ck_assert_str_eq(iast, str);
|
2020-10-16 09:00:05 +02:00
|
|
|
|
2021-12-28 21:23:49 +01:00
|
|
|
free(str);
|
2021-04-16 10:03:08 +02:00
|
|
|
}
|
2020-10-16 09:00:05 +02:00
|
|
|
|
2021-12-28 21:23:49 +01:00
|
|
|
START_TEST(test_velthuis_encoding)
|
2021-04-16 10:03:08 +02:00
|
|
|
{
|
2021-12-28 21:23:49 +01:00
|
|
|
test_velthuis("sa.msk.rtam", "saṃskṛtam");
|
|
|
|
test_velthuis("yoga.h", "yogaḥ");
|
|
|
|
test_velthuis("tantra\"saastram", "tantraśāstram");
|
|
|
|
test_velthuis("Aa Ii .Rr", "Ā Ī Ṝ");
|
|
|
|
test_velthuis("atha prathamo.adhyaaya.h", "atha prathamo'dhyāyaḥ");
|
2021-04-16 10:03:08 +02:00
|
|
|
}
|
|
|
|
END_TEST
|
2020-10-29 10:01:48 +01:00
|
|
|
|
2021-12-28 21:23:49 +01:00
|
|
|
START_TEST(test_encode_zwnj_and_zwj)
|
2021-04-16 10:03:08 +02:00
|
|
|
{
|
2021-12-28 21:23:49 +01:00
|
|
|
test_velthuis("ka+i", "ka"ZWJ"i");
|
|
|
|
test_velthuis("ka-i", "ka"ZWNJ"i");
|
2020-10-16 09:00:05 +02:00
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2021-12-28 21:23:49 +01:00
|
|
|
START_TEST(test_encode_oneway)
|
2021-05-02 21:14:56 +02:00
|
|
|
{
|
2021-12-28 21:23:49 +01:00
|
|
|
test_velthuis_oneway("puuu puu{}u pu{}uu", "pūu pūu puū");
|
2021-05-02 21:14:56 +02:00
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2020-10-16 09:00:05 +02:00
|
|
|
void register_velthuis_encoder_tests(TCase *test_case)
|
|
|
|
{
|
2021-12-28 21:23:49 +01:00
|
|
|
tcase_add_test(test_case, test_velthuis_encoding);
|
2021-05-02 21:14:56 +02:00
|
|
|
tcase_add_test(test_case, test_encode_zwnj_and_zwj);
|
2021-12-28 21:23:49 +01:00
|
|
|
tcase_add_test(test_case, test_encode_oneway);
|
2020-10-16 09:00:05 +02:00
|
|
|
}
|