From 9d14562f7e81441b244dc9b2e69004ad285a5ff2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emysl=20Eric=20Janouch?= Date: Mon, 12 Oct 2020 22:34:46 +0200 Subject: Improve the UTF-8 API We need to be able to detect partial sequences. --- tests/liberty.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tests') diff --git a/tests/liberty.c b/tests/liberty.c index 65847fe..b55fe2c 100644 --- a/tests/liberty.c +++ b/tests/liberty.c @@ -326,6 +326,11 @@ test_str_map (void) static void test_utf8 (void) { + const char *full = "\xc5\x99", *partial = full, *empty = full; + soft_assert (utf8_decode (&full, 2) == 0x0159); + soft_assert (utf8_decode (&partial, 1) == -2); + soft_assert (utf8_decode (&empty, 0) == -1); + const char valid [] = "2H₂ + O₂ ⇌ 2H₂O, R = 4.7 kΩ, ⌀ 200 mm"; const char invalid[] = "\xf0\x90\x28\xbc"; soft_assert ( utf8_validate (valid, sizeof valid)); -- cgit v1.2.3