aboutsummaryrefslogtreecommitdiff
path: root/tests/test-cutils.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2017-02-21 21:13:59 +0100
committerMarkus Armbruster <armbru@redhat.com>2017-02-23 20:35:36 +0100
commite591591b323772eea733de6027f5e8b50692d0ff (patch)
tree1ced565e53764f93f0f4951e07be2ad4ff183b40 /tests/test-cutils.c
parentd2734d2629266006b0413433778474d5801c60be (diff)
util/cutils: Rename qemu_strtosz() to qemu_strtosz_MiB()
With qemu_strtosz(), no suffix means mebibytes. It's used rarely. I'm going to add a similar function where no suffix means bytes. Rename qemu_strtosz() to qemu_strtosz_MiB() to make the name qemu_strtosz() available for the new function. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <1487708048-2131-16-git-send-email-armbru@redhat.com>
Diffstat (limited to 'tests/test-cutils.c')
-rw-r--r--tests/test-cutils.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/tests/test-cutils.c b/tests/test-cutils.c
index e1d40548c0..9bbfb8f8e2 100644
--- a/tests/test-cutils.c
+++ b/tests/test-cutils.c
@@ -1376,16 +1376,16 @@ static void test_qemu_strtosz_simple(void)
int64_t res;
str = "0";
- res = qemu_strtosz(str, &endptr);
+ res = qemu_strtosz_MiB(str, &endptr);
g_assert_cmpint(res, ==, 0);
g_assert(endptr == str + 1);
str = "12345M";
- res = qemu_strtosz(str, &endptr);
+ res = qemu_strtosz_MiB(str, &endptr);
g_assert_cmpint(res, ==, 12345 * M_BYTE);
g_assert(endptr == str + 6);
- res = qemu_strtosz(str, NULL);
+ res = qemu_strtosz_MiB(str, NULL);
g_assert_cmpint(res, ==, 12345 * M_BYTE);
/* Note: precision is 53 bits since we're parsing with strtod() */
@@ -1433,35 +1433,35 @@ static void test_qemu_strtosz_units(void)
int64_t res;
/* default is M */
- res = qemu_strtosz(none, &endptr);
+ res = qemu_strtosz_MiB(none, &endptr);
g_assert_cmpint(res, ==, M_BYTE);
g_assert(endptr == none + 1);
- res = qemu_strtosz(b, &endptr);
+ res = qemu_strtosz_MiB(b, &endptr);
g_assert_cmpint(res, ==, 1);
g_assert(endptr == b + 2);
- res = qemu_strtosz(k, &endptr);
+ res = qemu_strtosz_MiB(k, &endptr);
g_assert_cmpint(res, ==, K_BYTE);
g_assert(endptr == k + 2);
- res = qemu_strtosz(m, &endptr);
+ res = qemu_strtosz_MiB(m, &endptr);
g_assert_cmpint(res, ==, M_BYTE);
g_assert(endptr == m + 2);
- res = qemu_strtosz(g, &endptr);
+ res = qemu_strtosz_MiB(g, &endptr);
g_assert_cmpint(res, ==, G_BYTE);
g_assert(endptr == g + 2);
- res = qemu_strtosz(t, &endptr);
+ res = qemu_strtosz_MiB(t, &endptr);
g_assert_cmpint(res, ==, T_BYTE);
g_assert(endptr == t + 2);
- res = qemu_strtosz(p, &endptr);
+ res = qemu_strtosz_MiB(p, &endptr);
g_assert_cmpint(res, ==, P_BYTE);
g_assert(endptr == p + 2);
- res = qemu_strtosz(e, &endptr);
+ res = qemu_strtosz_MiB(e, &endptr);
g_assert_cmpint(res, ==, E_BYTE);
g_assert(endptr == e + 2);
}
@@ -1472,7 +1472,7 @@ static void test_qemu_strtosz_float(void)
char *endptr = NULL;
int64_t res;
- res = qemu_strtosz(str, &endptr);
+ res = qemu_strtosz_MiB(str, &endptr);
g_assert_cmpint(res, ==, 12.345 * M_BYTE);
g_assert(endptr == str + 7);
}
@@ -1484,17 +1484,17 @@ static void test_qemu_strtosz_invalid(void)
int64_t res;
str = "";
- res = qemu_strtosz(str, &endptr);
+ res = qemu_strtosz_MiB(str, &endptr);
g_assert_cmpint(res, ==, -EINVAL);
g_assert(endptr == str);
str = " \t ";
- res = qemu_strtosz(str, &endptr);
+ res = qemu_strtosz_MiB(str, &endptr);
g_assert_cmpint(res, ==, -EINVAL);
g_assert(endptr == str);
str = "crap";
- res = qemu_strtosz(str, &endptr);
+ res = qemu_strtosz_MiB(str, &endptr);
g_assert_cmpint(res, ==, -EINVAL);
g_assert(endptr == str);
}
@@ -1506,12 +1506,12 @@ static void test_qemu_strtosz_trailing(void)
int64_t res;
str = "123xxx";
- res = qemu_strtosz(str, &endptr);
+ res = qemu_strtosz_MiB(str, &endptr);
g_assert_cmpint(res, ==, 123 * M_BYTE);
g_assert(endptr == str + 3);
str = "1kiB";
- res = qemu_strtosz(str, &endptr);
+ res = qemu_strtosz_MiB(str, &endptr);
g_assert_cmpint(res, ==, 1024);
g_assert(endptr == str + 2);
}
@@ -1523,7 +1523,7 @@ static void test_qemu_strtosz_erange(void)
int64_t res;
str = "-1";
- res = qemu_strtosz(str, &endptr);
+ res = qemu_strtosz_MiB(str, &endptr);
g_assert_cmpint(res, ==, -ERANGE);
g_assert(endptr == str + 2);
@@ -1543,7 +1543,7 @@ static void test_qemu_strtosz_erange(void)
g_assert(endptr == str + 19);
str = "10E";
- res = qemu_strtosz(str, &endptr);
+ res = qemu_strtosz_MiB(str, &endptr);
g_assert_cmpint(res, ==, -ERANGE);
g_assert(endptr == str + 3);
}