9 #include <pulse/utf8.h>
10 #include <pulse/xmalloc.h>
11 #include <pulsecore/core-util.h>
13 START_TEST (utf8_valid
) {
14 fail_unless(pa_utf8_valid("hallo") != NULL
);
15 fail_unless(pa_utf8_valid("hallo\n") != NULL
);
16 fail_unless(pa_utf8_valid("hüpfburg\n") == NULL
);
17 fail_unless(pa_utf8_valid("hallo\n") != NULL
);
18 fail_unless(pa_utf8_valid("hüpfburg\n") != NULL
);
22 START_TEST (utf8_filter
) {
26 char res1
[] = { 0x68, 0x5f, 0x70, 0x66, 0x62, 0x75, 0x72, 0x67, '\0' };
27 c
= pa_utf8_filter("hüpfburg");
28 pa_log_debug("%s %s\n", res1
, c
);
29 fail_unless(pa_streq(c
, res1
));
34 char res2
[] = { 0x68, 0xc3, 0xbc, 0x70, 0x66, 0x62, 0x75, 0x72, 0x67, '\0' };
35 c
= pa_utf8_filter("hüpfburg");
36 fail_unless(pa_streq(c
, res2
));
37 pa_log_debug("%s %s\n", res2
, c
);
42 char res3
[] = { 0x5f, 0x78, 0x6b, 0x6e, 0x5f, 0x72, 0x7a, 0x6d, 0x5f, 0x72, 0x7a, 0x65, 0x6c, 0x74, 0x5f, 0x72, 0x73, 0x7a, 0xdf, 0xb3, 0x5f, 0x64, 0x73, 0x6a, 0x6b, 0x66, 0x68, '\0' };
43 c
= pa_utf8_filter("üxknärzmörzeltörszß³§dsjkfh");
44 pa_log_debug("%s %s\n", res3
, c
);
45 fail_unless(pa_streq(c
, res3
));
51 int main(int argc
, char *argv
[]) {
57 if (!getenv("MAKE_CHECK"))
58 pa_log_set_level(PA_LOG_DEBUG
);
60 s
= suite_create("UTF8");
61 tc
= tcase_create("utf8");
62 tcase_add_test(tc
, utf8_valid
);
63 tcase_add_test(tc
, utf8_filter
);
64 suite_add_tcase(s
, tc
);
66 sr
= srunner_create(s
);
67 srunner_run_all(sr
, CK_NORMAL
);
68 failed
= srunner_ntests_failed(sr
);
71 return (failed
== 0) ? EXIT_SUCCESS
: EXIT_FAILURE
;