Add some more strings that the user might send our way. In
particular, some of these additions include FIXME comments showing
where our parser doesn't quite behave the way we want.
Signed-off-by: Eric Blake <eblake@redhat.com>
---
v2: even more tests added, pad a string to avoid out-of-bounds
randomness [Hanna]
---
tests/unit/test-cutils.c | 147 +++++++++++++++++++++++++++++++++++----
1 file changed, 135 insertions(+), 12 deletions(-)
diff --git a/tests/unit/test-cutils.c b/tests/unit/test-cutils.c
index 1936c7b5795..7800caf9b0e 100644
--- a/tests/unit/test-cutils.c
+++ b/tests/unit/test-cutils.c
@@ -3162,7 +3162,12 @@ static void do_strtosz_full(const char *str,
qemu_strtosz_fn fn,
ret = fn(str, &endptr, &val);
g_assert_cmpint(ret, ==, exp_ptr_ret);
g_assert_cmpuint(val, ==, exp_ptr_val);
- g_assert_true(endptr == str + exp_ptr_offset);
+ if (str) {
+ g_assert_true(endptr == str + exp_ptr_offset);
+ } else {
+ g_assert_cmpint(exp_ptr_offset, ==, 0);
+ g_assert_null(endptr);
+ }