aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2023-01-23 12:08:21 -0600
committerDenis Kenzior <denkenz@gmail.com>2023-01-23 12:08:21 -0600
commit38b431bf77d418b9ea38279a1ac89c76eadd5674 (patch)
tree95bb88cde94e97825ce29f98df38c0c448d1fa4c
parent7b3ac120e9d76e0b8318c3e6b5393777f198b404 (diff)
unit: Add unit test for l_util_hexstringv
-rw-r--r--unit/test-util.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/unit/test-util.c b/unit/test-util.c
index 067a708b..5a2c5d10 100644
--- a/unit/test-util.c
+++ b/unit/test-util.c
@@ -39,6 +39,24 @@ static void test_hexstring(const void *test_data)
l_free(hex);
}
+static void test_hexstringv(const void *test_data)
+{
+ unsigned char test1[] = { 0x74, 0x65, 0x73, 0x74, 0x00 };
+ unsigned char test2[] = { 0x74, 0x65, 0x73 };
+ struct iovec iov[2];
+ char *hex;
+
+ iov[0].iov_base = test1;
+ iov[0].iov_len = 5;
+ iov[1].iov_base = test2;
+ iov[1].iov_len = 3;
+
+ hex = l_util_hexstringv(iov, 2);
+ assert(hex);
+ assert(!strcmp(hex, "7465737400746573"));
+ l_free(hex);
+}
+
static void test_hexstring_upper(const void *test_data)
{
unsigned char test[] = { 0x0a, 0x0b, 0x0c, 0xde, 0xf2 };
@@ -151,6 +169,7 @@ int main(int argc, char *argv[])
l_test_add("l_util_hexstring", test_hexstring, NULL);
l_test_add("l_util_hexstring_upper", test_hexstring_upper, NULL);
+ l_test_add("l_util_hexstringv", test_hexstringv, NULL);
l_test_add("l_util_from_hexstring", test_from_hexstring, NULL);
l_test_add("l_util_has_suffix", test_has_suffix, NULL);