aboutsummaryrefslogtreecommitdiff
path: root/tests/test-cutils.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2017-02-21 21:14:00 +0100
committerMarkus Armbruster <armbru@redhat.com>2017-02-23 20:35:36 +0100
commit466dea14e677555dd24465aca75d00a3537ad062 (patch)
treee1df0ed42f3bbac5bafe441aaad90b3d8ced3a3f /tests/test-cutils.c
parente591591b323772eea733de6027f5e8b50692d0ff (diff)
util/cutils: New qemu_strtosz()
Most callers of qemu_strtosz_suffix() pass QEMU_STRTOSZ_DEFSUFFIX_B. Capture the pattern in new qemu_strtosz(). Inline qemu_strtosz_suffix() into its only remaining caller. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <1487708048-2131-17-git-send-email-armbru@redhat.com>
Diffstat (limited to 'tests/test-cutils.c')
-rw-r--r--tests/test-cutils.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/tests/test-cutils.c b/tests/test-cutils.c
index 9bbfb8f8e2..9eae06761f 100644
--- a/tests/test-cutils.c
+++ b/tests/test-cutils.c
@@ -1391,27 +1391,27 @@ static void test_qemu_strtosz_simple(void)
/* Note: precision is 53 bits since we're parsing with strtod() */
str = "9007199254740991"; /* 2^53-1 */
- res = qemu_strtosz_suffix(str, &endptr, QEMU_STRTOSZ_DEFSUFFIX_B);
+ res = qemu_strtosz(str, &endptr);
g_assert_cmpint(res, ==, 0x1fffffffffffff);
g_assert(endptr == str + 16);
str = "9007199254740992"; /* 2^53 */
- res = qemu_strtosz_suffix(str, &endptr, QEMU_STRTOSZ_DEFSUFFIX_B);
+ res = qemu_strtosz(str, &endptr);
g_assert_cmpint(res, ==, 0x20000000000000);
g_assert(endptr == str + 16);
str = "9007199254740993"; /* 2^53+1 */
- res = qemu_strtosz_suffix(str, &endptr, QEMU_STRTOSZ_DEFSUFFIX_B);
+ res = qemu_strtosz(str, &endptr);
g_assert_cmpint(res, ==, 0x20000000000000); /* rounded to 53 bits */
g_assert(endptr == str + 16);
str = "9223372036854774784"; /* 0x7ffffffffffffc00 (53 msbs set) */
- res = qemu_strtosz_suffix(str, &endptr, QEMU_STRTOSZ_DEFSUFFIX_B);
+ res = qemu_strtosz(str, &endptr);
g_assert_cmpint(res, ==, 0x7ffffffffffffc00);
g_assert(endptr == str + 19);
str = "9223372036854775295"; /* 0x7ffffffffffffdff */
- res = qemu_strtosz_suffix(str, &endptr, QEMU_STRTOSZ_DEFSUFFIX_B);
+ res = qemu_strtosz(str, &endptr);
g_assert_cmpint(res, ==, 0x7ffffffffffffc00); /* rounded to 53 bits */
g_assert(endptr == str + 19);
@@ -1528,17 +1528,17 @@ static void test_qemu_strtosz_erange(void)
g_assert(endptr == str + 2);
str = "9223372036854775296"; /* 0x7ffffffffffffe00 */
- res = qemu_strtosz_suffix(str, &endptr, QEMU_STRTOSZ_DEFSUFFIX_B);
+ res = qemu_strtosz(str, &endptr);
g_assert_cmpint(res, ==, -ERANGE);
g_assert(endptr == str + 19);
str = "9223372036854775807"; /* 2^63-1 */
- res = qemu_strtosz_suffix(str, &endptr, QEMU_STRTOSZ_DEFSUFFIX_B);
+ res = qemu_strtosz(str, &endptr);
g_assert_cmpint(res, ==, -ERANGE);
g_assert(endptr == str + 19);
str = "9223372036854775808"; /* 2^63 */
- res = qemu_strtosz_suffix(str, &endptr, QEMU_STRTOSZ_DEFSUFFIX_B);
+ res = qemu_strtosz(str, &endptr);
g_assert_cmpint(res, ==, -ERANGE);
g_assert(endptr == str + 19);