]> code.delx.au - pulseaudio/commitdiff
add new test programme utf8-test.c
authorLennart Poettering <lennart@poettering.net>
Tue, 16 May 2006 00:46:03 +0000 (00:46 +0000)
committerLennart Poettering <lennart@poettering.net>
Tue, 16 May 2006 00:46:03 +0000 (00:46 +0000)
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@880 fefdeb5f-60dc-0310-8127-8f9354f1896f

src/Makefile.am
src/tests/utf8-test.c [new file with mode: 0644]

index 903359ada14f99bba6adbd0c9c3b51c94713d664..10dbf2f2dd0f56dd75836af6baca4c9e89ea3311 100644 (file)
@@ -189,7 +189,8 @@ noinst_PROGRAMS = \
                memblockq-test \
                sync-playback \
                channelmap-test \
-               thread-mainloop-test
+               thread-mainloop-test \
+               utf8-test
 
 if HAVE_SIGXCPU
 noinst_PROGRAMS += \
@@ -217,6 +218,11 @@ thread_mainloop_test_CFLAGS = $(AM_CFLAGS)
 thread_mainloop_test_LDADD = $(AM_LDADD) libpolyp-@PA_MAJORMINOR@.la
 thread_mainloop_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
+utf8_test_SOURCES = tests/utf8-test.c
+utf8_test_CFLAGS = $(AM_CFLAGS)
+utf8_test_LDADD = $(AM_LDADD) libpolypcore.la
+utf8_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
+
 mcalign_test_SOURCES = tests/mcalign-test.c
 mcalign_test_CFLAGS = $(AM_CFLAGS)
 mcalign_test_LDADD = $(AM_LDADD) $(WINSOCK_LIBS) libpolypcore.la
diff --git a/src/tests/utf8-test.c b/src/tests/utf8-test.c
new file mode 100644 (file)
index 0000000..c8b2fab
--- /dev/null
@@ -0,0 +1,26 @@
+/* $Id$ */
+
+#include <stdio.h>
+#include <assert.h>
+
+#include <polypcore/utf8.h>
+#include <polypcore/xmalloc.h>
+
+int main(int argc, char *argv[]) {
+    char *c;
+    
+    assert(pa_utf8_valid("hallo"));
+    assert(pa_utf8_valid("hallo\n"));
+    assert(!pa_utf8_valid("hüpfburg\n"));
+    assert(pa_utf8_valid("hallo\n"));
+    assert(pa_utf8_valid("hüpfburg\n"));
+    
+    printf("LATIN1: %s\n", c = pa_utf8_filter("hüpfburg"));
+    pa_xfree(c);
+    printf("UTF8: %sx\n", c = pa_utf8_filter("hüpfburg"));
+    pa_xfree(c);
+    printf("LATIN1: %sx\n", c = pa_utf8_filter("üxknärzmörzeltörszß³§dsjkfh"));
+    pa_xfree(c);
+
+    return 0;
+}