aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-12-29 12:22:28 -0500
committerAnthony G. Basile <blueness@gentoo.org>2014-12-29 12:22:28 -0500
commit54c92293a608f3412c4ad59ed2e85f1cc7a9d4da (patch)
treee9a2d341bbe0582ccddd307e9af73fb325e6dba9 /test
parentshared: utf8 - support ucs4 -> utf8 (diff)
downloadeudev-54c92293a608f3412c4ad59ed2e85f1cc7a9d4da.tar.gz
eudev-54c92293a608f3412c4ad59ed2e85f1cc7a9d4da.tar.bz2
eudev-54c92293a608f3412c4ad59ed2e85f1cc7a9d4da.zip
shared: utf8 - support decoding the full utf16
We originally only supported the BMP (i.e., we treated UTF-16 as UCS-2). Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'test')
-rw-r--r--test/test-utf8.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/test-utf8.c b/test/test-utf8.c
index bd8ca8683..2f0a95f1c 100644
--- a/test/test-utf8.c
+++ b/test/test-utf8.c
@@ -44,10 +44,23 @@ static void test_utf8_encoded_valid_unichar(void) {
}
+static void test_utf16_to_utf8(void) {
+ char *a = NULL;
+ const uint16_t utf16[] = { 'a', 0xd800, 'b', 0xdc00, 'c', 0xd801, 0xdc37 };
+ const char utf8[] = { 'a', 'b', 'c', 0xf0, 0x90, 0x90, 0xb7, 0 };
+
+ a = utf16_to_utf8(utf16, 14);
+ assert_se(a);
+ assert_se(streq(a, utf8));
+
+ free(a);
+}
+
int main(int argc, char *argv[]) {
test_utf8_is_printable();
test_ascii_is_valid();
test_utf8_encoded_valid_unichar();
+ test_utf16_to_utf8();
return 0;
}