utils: Tighter tests for qemu_strtosz
commit061d79097c080722e359db7c0d9cddc006cfb14d
authorEric Blake <eblake@redhat.com>
Tue, 23 Mar 2021 16:52:59 +0000 (23 16:52 +0000)
committerAlex Bennée <alex.bennee@linaro.org>
Wed, 24 Mar 2021 14:25:37 +0000 (24 14:25 +0000)
treea174b564fb61388d09884f529c7f3db9befcc9ee
parente5b024b93047db9126b382cbad49b70eea912dd6
utils: Tighter tests for qemu_strtosz

Our tests were not validating the return value in all cases, nor was
it guaranteeing our documented claim that 'res' is unchanged on error.
For that matter, it wasn't as thorough as the existing tests for
qemu_strtoi() and friends for proving that endptr and res are sanely
set.  Enhancing the test found one case where we violated our
documentation: namely, when failing with EINVAL when endptr is NULL,
we shouldn't modify res.

Signed-off-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20210317143325.2165821-2-eblake@redhat.com>
Message-Id: <20210323165308.15244-14-alex.bennee@linaro.org>
tests/unit/test-cutils.c
util/cutils.c