4 #include "../../compiler/compiler.h"
5 #include "../../lib/num2str.h"
6 #include "../unittest.h"
17 static const struct testcase testcases[] = {
18 { 1, 1, 1, 0, N2S_NONE, "1" },
19 { UINT64_MAX, 99, 1, 0, N2S_NONE, "18446744073709551615" },
20 { 18446744073709551, 2, 1, 0, N2S_NONE, "18P" },
21 { 18446744073709551, 4, 1, 0, N2S_NONE, "18.4P" },
22 { UINT64_MAX, 2, 1, 0, N2S_NONE, "18E" },
23 { UINT64_MAX, 4, 1, 0, N2S_NONE, "18.4E" },
26 static void test_num2str(void)
28 const struct testcase *p;
32 for (i = 0; i < ARRAY_SIZE(testcases); ++i) {
34 str = num2str(p->num, p->maxlen, p->base, p->pow2, p->unit);
35 CU_ASSERT_STRING_EQUAL(str, p->expected);
40 static struct fio_unittest_entry tests[] = {
50 CU_ErrorCode fio_unittest_lib_num2str(void)
52 return fio_unittest_add_suite("lib/num2str.c", NULL, NULL, tests);