aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2024-02-05 21:59:31 -0600
committerDenis Kenzior <denkenz@gmail.com>2024-02-05 22:02:33 -0600
commit42236179c9904fb4d0849e0005859cb9a2b544a0 (patch)
tree6810503616f7636b0379d1f381d503525e89d469
parent86c28534cd47934fcee63bbad80c64e1e1a47392 (diff)
unit: Add unit tests for l_ascii_touppwer/lower
-rw-r--r--unit/test-utf8.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/unit/test-utf8.c b/unit/test-utf8.c
index 1ca2a1c8..7473bf2f 100644
--- a/unit/test-utf8.c
+++ b/unit/test-utf8.c
@@ -1,6 +1,7 @@
/*
* Embedded Linux library
* Copyright (C) 2011-2014 Intel Corporation
+ * Copyright (C) 2024 Cruise, LLC
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
@@ -919,6 +920,30 @@ static void test_utf8_to_utf16(const void *test_data)
l_free(utf16);
}
+static void test_ascii_toupper(const void *data)
+{
+ assert(l_ascii_toupper('c') == 'C');
+ assert(l_ascii_toupper('z') == 'Z');
+ assert(l_ascii_toupper('a') == 'A');
+ assert(l_ascii_toupper('A') == 'A');
+ assert(l_ascii_toupper('Z') == 'Z');
+ assert(l_ascii_toupper(' ') == ' ');
+ assert(l_ascii_toupper('0') == '0');
+ assert(l_ascii_toupper('9') == '9');
+}
+
+static void test_ascii_tolower(const void *data)
+{
+ assert(l_ascii_tolower('c') == 'c');
+ assert(l_ascii_tolower('z') == 'z');
+ assert(l_ascii_tolower('a') == 'a');
+ assert(l_ascii_tolower('A') == 'a');
+ assert(l_ascii_tolower('Z') == 'z');
+ assert(l_ascii_tolower(' ') == ' ');
+ assert(l_ascii_tolower('0') == '0');
+ assert(l_ascii_tolower('9') == '9');
+}
+
int main(int argc, char *argv[])
{
l_test_init(&argc, &argv);
@@ -1101,5 +1126,8 @@ int main(int argc, char *argv[])
l_test_add("utf8_to_utf16 2", test_utf8_to_utf16,
&utf8_from_utf16_test2);
+ l_test_add("ascii/toupper", test_ascii_toupper, NULL);
+ l_test_add("ascii/tolower", test_ascii_tolower, NULL);
+
return l_test_run();
}