tests: modify queue-test to use 'check' framework
[pulseaudio-raopUDP/pulseaudio-raop-alac.git] / src / tests / utf8-test.c
blob22a58c08f001673bc97deb12d294cb6476022bd6
1 #ifdef HAVE_CONFIG_H
2 #include <config.h>
3 #endif
5 #include <stdio.h>
6 #include <assert.h>
7 #include <check.h>
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);
20 END_TEST
22 START_TEST (utf8_filter) {
23 char *c;
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));
30 pa_xfree(c);
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);
38 pa_xfree(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));
46 pa_xfree(c);
49 END_TEST
51 int main(int argc, char *argv[]) {
52 int failed = 0;
53 Suite *s;
54 TCase *tc;
55 SRunner *sr;
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);
69 srunner_free(sr);
71 return (failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;