aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2020-10-12 22:34:46 +0200
committerPřemysl Eric Janouch <p@janouch.name>2020-10-12 22:56:22 +0200
commit9d14562f7e81441b244dc9b2e69004ad285a5ff2 (patch)
tree08c44be11f4023f6bd4a008d64c28c67dcd1b07b /tests
parent9b723049635329feda63fab675df794e429aa151 (diff)
downloadliberty-9d14562f7e81441b244dc9b2e69004ad285a5ff2.tar.gz
liberty-9d14562f7e81441b244dc9b2e69004ad285a5ff2.tar.xz
liberty-9d14562f7e81441b244dc9b2e69004ad285a5ff2.zip
Improve the UTF-8 API
We need to be able to detect partial sequences.
Diffstat (limited to 'tests')
-rw-r--r--tests/liberty.c5
1 files changed, 5 insertions, 0 deletions
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));