vhdx: Simplify vhdx_set_shift_bits()
[qemu.git] / tests / test-cutils.c
blob398700df45ab6edeb2bf2a559db177931ec41ffa
1 /*
2 * cutils.c unit-tests
4 * Copyright (C) 2013 Red Hat Inc.
6 * Authors:
7 * Eduardo Habkost <ehabkost@redhat.com>
9 * Permission is hereby granted, free of charge, to any person obtaining a copy
10 * of this software and associated documentation files (the "Software"), to deal
11 * in the Software without restriction, including without limitation the rights
12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 * copies of the Software, and to permit persons to whom the Software is
14 * furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included in
17 * all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 * THE SOFTWARE.
28 #include "qemu/osdep.h"
29 #include <glib.h>
31 #include "qemu-common.h"
34 static void test_parse_uint_null(void)
36 unsigned long long i = 999;
37 char f = 'X';
38 char *endptr = &f;
39 int r;
41 r = parse_uint(NULL, &i, &endptr, 0);
43 g_assert_cmpint(r, ==, -EINVAL);
44 g_assert_cmpint(i, ==, 0);
45 g_assert(endptr == NULL);
48 static void test_parse_uint_empty(void)
50 unsigned long long i = 999;
51 char f = 'X';
52 char *endptr = &f;
53 const char *str = "";
54 int r;
56 r = parse_uint(str, &i, &endptr, 0);
58 g_assert_cmpint(r, ==, -EINVAL);
59 g_assert_cmpint(i, ==, 0);
60 g_assert(endptr == str);
63 static void test_parse_uint_whitespace(void)
65 unsigned long long i = 999;
66 char f = 'X';
67 char *endptr = &f;
68 const char *str = " \t ";
69 int r;
71 r = parse_uint(str, &i, &endptr, 0);
73 g_assert_cmpint(r, ==, -EINVAL);
74 g_assert_cmpint(i, ==, 0);
75 g_assert(endptr == str);
79 static void test_parse_uint_invalid(void)
81 unsigned long long i = 999;
82 char f = 'X';
83 char *endptr = &f;
84 const char *str = " \t xxx";
85 int r;
87 r = parse_uint(str, &i, &endptr, 0);
89 g_assert_cmpint(r, ==, -EINVAL);
90 g_assert_cmpint(i, ==, 0);
91 g_assert(endptr == str);
95 static void test_parse_uint_trailing(void)
97 unsigned long long i = 999;
98 char f = 'X';
99 char *endptr = &f;
100 const char *str = "123xxx";
101 int r;
103 r = parse_uint(str, &i, &endptr, 0);
105 g_assert_cmpint(r, ==, 0);
106 g_assert_cmpint(i, ==, 123);
107 g_assert(endptr == str + 3);
110 static void test_parse_uint_correct(void)
112 unsigned long long i = 999;
113 char f = 'X';
114 char *endptr = &f;
115 const char *str = "123";
116 int r;
118 r = parse_uint(str, &i, &endptr, 0);
120 g_assert_cmpint(r, ==, 0);
121 g_assert_cmpint(i, ==, 123);
122 g_assert(endptr == str + strlen(str));
125 static void test_parse_uint_octal(void)
127 unsigned long long i = 999;
128 char f = 'X';
129 char *endptr = &f;
130 const char *str = "0123";
131 int r;
133 r = parse_uint(str, &i, &endptr, 0);
135 g_assert_cmpint(r, ==, 0);
136 g_assert_cmpint(i, ==, 0123);
137 g_assert(endptr == str + strlen(str));
140 static void test_parse_uint_decimal(void)
142 unsigned long long i = 999;
143 char f = 'X';
144 char *endptr = &f;
145 const char *str = "0123";
146 int r;
148 r = parse_uint(str, &i, &endptr, 10);
150 g_assert_cmpint(r, ==, 0);
151 g_assert_cmpint(i, ==, 123);
152 g_assert(endptr == str + strlen(str));
156 static void test_parse_uint_llong_max(void)
158 unsigned long long i = 999;
159 char f = 'X';
160 char *endptr = &f;
161 char *str = g_strdup_printf("%llu", (unsigned long long)LLONG_MAX + 1);
162 int r;
164 r = parse_uint(str, &i, &endptr, 0);
166 g_assert_cmpint(r, ==, 0);
167 g_assert_cmpint(i, ==, (unsigned long long)LLONG_MAX + 1);
168 g_assert(endptr == str + strlen(str));
170 g_free(str);
173 static void test_parse_uint_overflow(void)
175 unsigned long long i = 999;
176 char f = 'X';
177 char *endptr = &f;
178 const char *str = "99999999999999999999999999999999999999";
179 int r;
181 r = parse_uint(str, &i, &endptr, 0);
183 g_assert_cmpint(r, ==, -ERANGE);
184 g_assert_cmpint(i, ==, ULLONG_MAX);
185 g_assert(endptr == str + strlen(str));
188 static void test_parse_uint_negative(void)
190 unsigned long long i = 999;
191 char f = 'X';
192 char *endptr = &f;
193 const char *str = " \t -321";
194 int r;
196 r = parse_uint(str, &i, &endptr, 0);
198 g_assert_cmpint(r, ==, -ERANGE);
199 g_assert_cmpint(i, ==, 0);
200 g_assert(endptr == str + strlen(str));
204 static void test_parse_uint_full_trailing(void)
206 unsigned long long i = 999;
207 const char *str = "123xxx";
208 int r;
210 r = parse_uint_full(str, &i, 0);
212 g_assert_cmpint(r, ==, -EINVAL);
213 g_assert_cmpint(i, ==, 0);
216 static void test_parse_uint_full_correct(void)
218 unsigned long long i = 999;
219 const char *str = "123";
220 int r;
222 r = parse_uint_full(str, &i, 0);
224 g_assert_cmpint(r, ==, 0);
225 g_assert_cmpint(i, ==, 123);
228 static void test_qemu_strtol_correct(void)
230 const char *str = "12345 foo";
231 char f = 'X';
232 const char *endptr = &f;
233 long res = 999;
234 int err;
236 err = qemu_strtol(str, &endptr, 0, &res);
238 g_assert_cmpint(err, ==, 0);
239 g_assert_cmpint(res, ==, 12345);
240 g_assert(endptr == str + 5);
243 static void test_qemu_strtol_null(void)
245 char f = 'X';
246 const char *endptr = &f;
247 long res = 999;
248 int err;
250 err = qemu_strtol(NULL, &endptr, 0, &res);
252 g_assert_cmpint(err, ==, -EINVAL);
253 g_assert(endptr == NULL);
256 static void test_qemu_strtol_empty(void)
258 const char *str = "";
259 char f = 'X';
260 const char *endptr = &f;
261 long res = 999;
262 int err;
264 err = qemu_strtol(str, &endptr, 0, &res);
266 g_assert_cmpint(err, ==, -EINVAL);
269 static void test_qemu_strtol_whitespace(void)
271 const char *str = " \t ";
272 char f = 'X';
273 const char *endptr = &f;
274 long res = 999;
275 int err;
277 err = qemu_strtol(str, &endptr, 0, &res);
279 g_assert_cmpint(err, ==, -EINVAL);
282 static void test_qemu_strtol_invalid(void)
284 const char *str = " xxxx \t abc";
285 char f = 'X';
286 const char *endptr = &f;
287 long res = 999;
288 int err;
290 err = qemu_strtol(str, &endptr, 0, &res);
292 g_assert_cmpint(err, ==, -EINVAL);
295 static void test_qemu_strtol_trailing(void)
297 const char *str = "123xxx";
298 char f = 'X';
299 const char *endptr = &f;
300 long res = 999;
301 int err;
303 err = qemu_strtol(str, &endptr, 0, &res);
305 g_assert_cmpint(err, ==, 0);
306 g_assert_cmpint(res, ==, 123);
307 g_assert(endptr == str + 3);
310 static void test_qemu_strtol_octal(void)
312 const char *str = "0123";
313 char f = 'X';
314 const char *endptr = &f;
315 long res = 999;
316 int err;
318 err = qemu_strtol(str, &endptr, 8, &res);
320 g_assert_cmpint(err, ==, 0);
321 g_assert_cmpint(res, ==, 0123);
322 g_assert(endptr == str + strlen(str));
324 res = 999;
325 endptr = &f;
326 err = qemu_strtol(str, &endptr, 0, &res);
328 g_assert_cmpint(err, ==, 0);
329 g_assert_cmpint(res, ==, 0123);
330 g_assert(endptr == str + strlen(str));
333 static void test_qemu_strtol_decimal(void)
335 const char *str = "0123";
336 char f = 'X';
337 const char *endptr = &f;
338 long res = 999;
339 int err;
341 err = qemu_strtol(str, &endptr, 10, &res);
343 g_assert_cmpint(err, ==, 0);
344 g_assert_cmpint(res, ==, 123);
345 g_assert(endptr == str + strlen(str));
347 str = "123";
348 res = 999;
349 endptr = &f;
350 err = qemu_strtol(str, &endptr, 0, &res);
352 g_assert_cmpint(err, ==, 0);
353 g_assert_cmpint(res, ==, 123);
354 g_assert(endptr == str + strlen(str));
357 static void test_qemu_strtol_hex(void)
359 const char *str = "0123";
360 char f = 'X';
361 const char *endptr = &f;
362 long res = 999;
363 int err;
365 err = qemu_strtol(str, &endptr, 16, &res);
367 g_assert_cmpint(err, ==, 0);
368 g_assert_cmpint(res, ==, 0x123);
369 g_assert(endptr == str + strlen(str));
371 str = "0x123";
372 res = 999;
373 endptr = &f;
374 err = qemu_strtol(str, &endptr, 0, &res);
376 g_assert_cmpint(err, ==, 0);
377 g_assert_cmpint(res, ==, 0x123);
378 g_assert(endptr == str + strlen(str));
381 static void test_qemu_strtol_max(void)
383 const char *str = g_strdup_printf("%ld", LONG_MAX);
384 char f = 'X';
385 const char *endptr = &f;
386 long res = 999;
387 int err;
389 err = qemu_strtol(str, &endptr, 0, &res);
391 g_assert_cmpint(err, ==, 0);
392 g_assert_cmpint(res, ==, LONG_MAX);
393 g_assert(endptr == str + strlen(str));
396 static void test_qemu_strtol_overflow(void)
398 const char *str = "99999999999999999999999999999999999999999999";
399 char f = 'X';
400 const char *endptr = &f;
401 long res = 999;
402 int err;
404 err = qemu_strtol(str, &endptr, 0, &res);
406 g_assert_cmpint(err, ==, -ERANGE);
407 g_assert_cmpint(res, ==, LONG_MAX);
408 g_assert(endptr == str + strlen(str));
411 static void test_qemu_strtol_underflow(void)
413 const char *str = "-99999999999999999999999999999999999999999999";
414 char f = 'X';
415 const char *endptr = &f;
416 long res = 999;
417 int err;
419 err = qemu_strtol(str, &endptr, 0, &res);
421 g_assert_cmpint(err, ==, -ERANGE);
422 g_assert_cmpint(res, ==, LONG_MIN);
423 g_assert(endptr == str + strlen(str));
426 static void test_qemu_strtol_negative(void)
428 const char *str = " \t -321";
429 char f = 'X';
430 const char *endptr = &f;
431 long res = 999;
432 int err;
434 err = qemu_strtol(str, &endptr, 0, &res);
436 g_assert_cmpint(err, ==, 0);
437 g_assert_cmpint(res, ==, -321);
438 g_assert(endptr == str + strlen(str));
441 static void test_qemu_strtol_full_correct(void)
443 const char *str = "123";
444 long res = 999;
445 int err;
447 err = qemu_strtol(str, NULL, 0, &res);
449 g_assert_cmpint(err, ==, 0);
450 g_assert_cmpint(res, ==, 123);
453 static void test_qemu_strtol_full_null(void)
455 char f = 'X';
456 const char *endptr = &f;
457 long res = 999;
458 int err;
460 err = qemu_strtol(NULL, &endptr, 0, &res);
462 g_assert_cmpint(err, ==, -EINVAL);
463 g_assert(endptr == NULL);
466 static void test_qemu_strtol_full_empty(void)
468 const char *str = "";
469 long res = 999L;
470 int err;
472 err = qemu_strtol(str, NULL, 0, &res);
474 g_assert_cmpint(err, ==, -EINVAL);
477 static void test_qemu_strtol_full_negative(void)
479 const char *str = " \t -321";
480 long res = 999;
481 int err;
483 err = qemu_strtol(str, NULL, 0, &res);
485 g_assert_cmpint(err, ==, 0);
486 g_assert_cmpint(res, ==, -321);
489 static void test_qemu_strtol_full_trailing(void)
491 const char *str = "123xxx";
492 long res;
493 int err;
495 err = qemu_strtol(str, NULL, 0, &res);
497 g_assert_cmpint(err, ==, -EINVAL);
500 static void test_qemu_strtol_full_max(void)
502 const char *str = g_strdup_printf("%ld", LONG_MAX);
503 long res;
504 int err;
506 err = qemu_strtol(str, NULL, 0, &res);
508 g_assert_cmpint(err, ==, 0);
509 g_assert_cmpint(res, ==, LONG_MAX);
512 static void test_qemu_strtoul_correct(void)
514 const char *str = "12345 foo";
515 char f = 'X';
516 const char *endptr = &f;
517 unsigned long res = 999;
518 int err;
520 err = qemu_strtoul(str, &endptr, 0, &res);
522 g_assert_cmpint(err, ==, 0);
523 g_assert_cmpint(res, ==, 12345);
524 g_assert(endptr == str + 5);
527 static void test_qemu_strtoul_null(void)
529 char f = 'X';
530 const char *endptr = &f;
531 unsigned long res = 999;
532 int err;
534 err = qemu_strtoul(NULL, &endptr, 0, &res);
536 g_assert_cmpint(err, ==, -EINVAL);
537 g_assert(endptr == NULL);
540 static void test_qemu_strtoul_empty(void)
542 const char *str = "";
543 char f = 'X';
544 const char *endptr = &f;
545 unsigned long res = 999;
546 int err;
548 err = qemu_strtoul(str, &endptr, 0, &res);
550 g_assert_cmpint(err, ==, -EINVAL);
553 static void test_qemu_strtoul_whitespace(void)
555 const char *str = " \t ";
556 char f = 'X';
557 const char *endptr = &f;
558 unsigned long res = 999;
559 int err;
561 err = qemu_strtoul(str, &endptr, 0, &res);
563 g_assert_cmpint(err, ==, -EINVAL);
566 static void test_qemu_strtoul_invalid(void)
568 const char *str = " xxxx \t abc";
569 char f = 'X';
570 const char *endptr = &f;
571 unsigned long res = 999;
572 int err;
574 err = qemu_strtoul(str, &endptr, 0, &res);
576 g_assert_cmpint(err, ==, -EINVAL);
579 static void test_qemu_strtoul_trailing(void)
581 const char *str = "123xxx";
582 char f = 'X';
583 const char *endptr = &f;
584 unsigned long res = 999;
585 int err;
587 err = qemu_strtoul(str, &endptr, 0, &res);
589 g_assert_cmpint(err, ==, 0);
590 g_assert_cmpint(res, ==, 123);
591 g_assert(endptr == str + 3);
594 static void test_qemu_strtoul_octal(void)
596 const char *str = "0123";
597 char f = 'X';
598 const char *endptr = &f;
599 unsigned long res = 999;
600 int err;
602 err = qemu_strtoul(str, &endptr, 8, &res);
604 g_assert_cmpint(err, ==, 0);
605 g_assert_cmpint(res, ==, 0123);
606 g_assert(endptr == str + strlen(str));
608 res = 999;
609 endptr = &f;
610 err = qemu_strtoul(str, &endptr, 0, &res);
612 g_assert_cmpint(err, ==, 0);
613 g_assert_cmpint(res, ==, 0123);
614 g_assert(endptr == str + strlen(str));
617 static void test_qemu_strtoul_decimal(void)
619 const char *str = "0123";
620 char f = 'X';
621 const char *endptr = &f;
622 unsigned long res = 999;
623 int err;
625 err = qemu_strtoul(str, &endptr, 10, &res);
627 g_assert_cmpint(err, ==, 0);
628 g_assert_cmpint(res, ==, 123);
629 g_assert(endptr == str + strlen(str));
631 str = "123";
632 res = 999;
633 endptr = &f;
634 err = qemu_strtoul(str, &endptr, 0, &res);
636 g_assert_cmpint(err, ==, 0);
637 g_assert_cmpint(res, ==, 123);
638 g_assert(endptr == str + strlen(str));
641 static void test_qemu_strtoul_hex(void)
643 const char *str = "0123";
644 char f = 'X';
645 const char *endptr = &f;
646 unsigned long res = 999;
647 int err;
649 err = qemu_strtoul(str, &endptr, 16, &res);
651 g_assert_cmpint(err, ==, 0);
652 g_assert_cmpint(res, ==, 0x123);
653 g_assert(endptr == str + strlen(str));
655 str = "0x123";
656 res = 999;
657 endptr = &f;
658 err = qemu_strtoul(str, &endptr, 0, &res);
660 g_assert_cmpint(err, ==, 0);
661 g_assert_cmpint(res, ==, 0x123);
662 g_assert(endptr == str + strlen(str));
665 static void test_qemu_strtoul_max(void)
667 const char *str = g_strdup_printf("%lu", ULONG_MAX);
668 char f = 'X';
669 const char *endptr = &f;
670 unsigned long res = 999;
671 int err;
673 err = qemu_strtoul(str, &endptr, 0, &res);
675 g_assert_cmpint(err, ==, 0);
676 g_assert_cmpint(res, ==, ULONG_MAX);
677 g_assert(endptr == str + strlen(str));
680 static void test_qemu_strtoul_overflow(void)
682 const char *str = "99999999999999999999999999999999999999999999";
683 char f = 'X';
684 const char *endptr = &f;
685 unsigned long res = 999;
686 int err;
688 err = qemu_strtoul(str, &endptr, 0, &res);
690 g_assert_cmpint(err, ==, -ERANGE);
691 g_assert_cmpint(res, ==, ULONG_MAX);
692 g_assert(endptr == str + strlen(str));
695 static void test_qemu_strtoul_underflow(void)
697 const char *str = "-99999999999999999999999999999999999999999999";
698 char f = 'X';
699 const char *endptr = &f;
700 unsigned long res = 999;
701 int err;
703 err = qemu_strtoul(str, &endptr, 0, &res);
705 g_assert_cmpint(err, ==, -ERANGE);
706 g_assert_cmpint(res, ==, -1ul);
707 g_assert(endptr == str + strlen(str));
710 static void test_qemu_strtoul_negative(void)
712 const char *str = " \t -321";
713 char f = 'X';
714 const char *endptr = &f;
715 unsigned long res = 999;
716 int err;
718 err = qemu_strtoul(str, &endptr, 0, &res);
720 g_assert_cmpint(err, ==, 0);
721 g_assert_cmpint(res, ==, -321ul);
722 g_assert(endptr == str + strlen(str));
725 static void test_qemu_strtoul_full_correct(void)
727 const char *str = "123";
728 unsigned long res = 999;
729 int err;
731 err = qemu_strtoul(str, NULL, 0, &res);
733 g_assert_cmpint(err, ==, 0);
734 g_assert_cmpint(res, ==, 123);
737 static void test_qemu_strtoul_full_null(void)
739 unsigned long res = 999;
740 int err;
742 err = qemu_strtoul(NULL, NULL, 0, &res);
744 g_assert_cmpint(err, ==, -EINVAL);
747 static void test_qemu_strtoul_full_empty(void)
749 const char *str = "";
750 unsigned long res = 999;
751 int err;
753 err = qemu_strtoul(str, NULL, 0, &res);
755 g_assert_cmpint(err, ==, -EINVAL);
757 static void test_qemu_strtoul_full_negative(void)
759 const char *str = " \t -321";
760 unsigned long res = 999;
761 int err;
763 err = qemu_strtoul(str, NULL, 0, &res);
764 g_assert_cmpint(err, ==, 0);
765 g_assert_cmpint(res, ==, -321ul);
768 static void test_qemu_strtoul_full_trailing(void)
770 const char *str = "123xxx";
771 unsigned long res;
772 int err;
774 err = qemu_strtoul(str, NULL, 0, &res);
776 g_assert_cmpint(err, ==, -EINVAL);
779 static void test_qemu_strtoul_full_max(void)
781 const char *str = g_strdup_printf("%lu", ULONG_MAX);
782 unsigned long res = 999;
783 int err;
785 err = qemu_strtoul(str, NULL, 0, &res);
787 g_assert_cmpint(err, ==, 0);
788 g_assert_cmpint(res, ==, ULONG_MAX);
791 static void test_qemu_strtoll_correct(void)
793 const char *str = "12345 foo";
794 char f = 'X';
795 const char *endptr = &f;
796 int64_t res = 999;
797 int err;
799 err = qemu_strtoll(str, &endptr, 0, &res);
801 g_assert_cmpint(err, ==, 0);
802 g_assert_cmpint(res, ==, 12345);
803 g_assert(endptr == str + 5);
806 static void test_qemu_strtoll_null(void)
808 char f = 'X';
809 const char *endptr = &f;
810 int64_t res = 999;
811 int err;
813 err = qemu_strtoll(NULL, &endptr, 0, &res);
815 g_assert_cmpint(err, ==, -EINVAL);
816 g_assert(endptr == NULL);
819 static void test_qemu_strtoll_empty(void)
821 const char *str = "";
822 char f = 'X';
823 const char *endptr = &f;
824 int64_t res = 999;
825 int err;
827 err = qemu_strtoll(str, &endptr, 0, &res);
829 g_assert_cmpint(err, ==, -EINVAL);
832 static void test_qemu_strtoll_whitespace(void)
834 const char *str = " \t ";
835 char f = 'X';
836 const char *endptr = &f;
837 int64_t res = 999;
838 int err;
840 err = qemu_strtoll(str, &endptr, 0, &res);
842 g_assert_cmpint(err, ==, -EINVAL);
845 static void test_qemu_strtoll_invalid(void)
847 const char *str = " xxxx \t abc";
848 char f = 'X';
849 const char *endptr = &f;
850 int64_t res = 999;
851 int err;
853 err = qemu_strtoll(str, &endptr, 0, &res);
855 g_assert_cmpint(err, ==, -EINVAL);
858 static void test_qemu_strtoll_trailing(void)
860 const char *str = "123xxx";
861 char f = 'X';
862 const char *endptr = &f;
863 int64_t res = 999;
864 int err;
866 err = qemu_strtoll(str, &endptr, 0, &res);
868 g_assert_cmpint(err, ==, 0);
869 g_assert_cmpint(res, ==, 123);
870 g_assert(endptr == str + 3);
873 static void test_qemu_strtoll_octal(void)
875 const char *str = "0123";
876 char f = 'X';
877 const char *endptr = &f;
878 int64_t res = 999;
879 int err;
881 err = qemu_strtoll(str, &endptr, 8, &res);
883 g_assert_cmpint(err, ==, 0);
884 g_assert_cmpint(res, ==, 0123);
885 g_assert(endptr == str + strlen(str));
887 endptr = &f;
888 res = 999;
889 err = qemu_strtoll(str, &endptr, 0, &res);
891 g_assert_cmpint(err, ==, 0);
892 g_assert_cmpint(res, ==, 0123);
893 g_assert(endptr == str + strlen(str));
896 static void test_qemu_strtoll_decimal(void)
898 const char *str = "0123";
899 char f = 'X';
900 const char *endptr = &f;
901 int64_t res = 999;
902 int err;
904 err = qemu_strtoll(str, &endptr, 10, &res);
906 g_assert_cmpint(err, ==, 0);
907 g_assert_cmpint(res, ==, 123);
908 g_assert(endptr == str + strlen(str));
910 str = "123";
911 endptr = &f;
912 res = 999;
913 err = qemu_strtoll(str, &endptr, 0, &res);
915 g_assert_cmpint(err, ==, 0);
916 g_assert_cmpint(res, ==, 123);
917 g_assert(endptr == str + strlen(str));
920 static void test_qemu_strtoll_hex(void)
922 const char *str = "0123";
923 char f = 'X';
924 const char *endptr = &f;
925 int64_t res = 999;
926 int err;
928 err = qemu_strtoll(str, &endptr, 16, &res);
930 g_assert_cmpint(err, ==, 0);
931 g_assert_cmpint(res, ==, 0x123);
932 g_assert(endptr == str + strlen(str));
934 str = "0x123";
935 endptr = &f;
936 res = 999;
937 err = qemu_strtoll(str, &endptr, 0, &res);
939 g_assert_cmpint(err, ==, 0);
940 g_assert_cmpint(res, ==, 0x123);
941 g_assert(endptr == str + strlen(str));
944 static void test_qemu_strtoll_max(void)
946 const char *str = g_strdup_printf("%lld", LLONG_MAX);
947 char f = 'X';
948 const char *endptr = &f;
949 int64_t res = 999;
950 int err;
952 err = qemu_strtoll(str, &endptr, 0, &res);
954 g_assert_cmpint(err, ==, 0);
955 g_assert_cmpint(res, ==, LLONG_MAX);
956 g_assert(endptr == str + strlen(str));
959 static void test_qemu_strtoll_overflow(void)
961 const char *str = "99999999999999999999999999999999999999999999";
962 char f = 'X';
963 const char *endptr = &f;
964 int64_t res = 999;
965 int err;
967 err = qemu_strtoll(str, &endptr, 0, &res);
969 g_assert_cmpint(err, ==, -ERANGE);
970 g_assert_cmpint(res, ==, LLONG_MAX);
971 g_assert(endptr == str + strlen(str));
974 static void test_qemu_strtoll_underflow(void)
976 const char *str = "-99999999999999999999999999999999999999999999";
977 char f = 'X';
978 const char *endptr = &f;
979 int64_t res = 999;
980 int err;
982 err = qemu_strtoll(str, &endptr, 0, &res);
984 g_assert_cmpint(err, ==, -ERANGE);
985 g_assert_cmpint(res, ==, LLONG_MIN);
986 g_assert(endptr == str + strlen(str));
989 static void test_qemu_strtoll_negative(void)
991 const char *str = " \t -321";
992 char f = 'X';
993 const char *endptr = &f;
994 int64_t res = 999;
995 int err;
997 err = qemu_strtoll(str, &endptr, 0, &res);
999 g_assert_cmpint(err, ==, 0);
1000 g_assert_cmpint(res, ==, -321);
1001 g_assert(endptr == str + strlen(str));
1004 static void test_qemu_strtoll_full_correct(void)
1006 const char *str = "123";
1007 int64_t res = 999;
1008 int err;
1010 err = qemu_strtoll(str, NULL, 0, &res);
1012 g_assert_cmpint(err, ==, 0);
1013 g_assert_cmpint(res, ==, 123);
1016 static void test_qemu_strtoll_full_null(void)
1018 int64_t res = 999;
1019 int err;
1021 err = qemu_strtoll(NULL, NULL, 0, &res);
1023 g_assert_cmpint(err, ==, -EINVAL);
1026 static void test_qemu_strtoll_full_empty(void)
1028 const char *str = "";
1029 int64_t res = 999;
1030 int err;
1032 err = qemu_strtoll(str, NULL, 0, &res);
1034 g_assert_cmpint(err, ==, -EINVAL);
1037 static void test_qemu_strtoll_full_negative(void)
1039 const char *str = " \t -321";
1040 int64_t res = 999;
1041 int err;
1043 err = qemu_strtoll(str, NULL, 0, &res);
1045 g_assert_cmpint(err, ==, 0);
1046 g_assert_cmpint(res, ==, -321);
1049 static void test_qemu_strtoll_full_trailing(void)
1051 const char *str = "123xxx";
1052 int64_t res = 999;
1053 int err;
1055 err = qemu_strtoll(str, NULL, 0, &res);
1057 g_assert_cmpint(err, ==, -EINVAL);
1060 static void test_qemu_strtoll_full_max(void)
1063 const char *str = g_strdup_printf("%lld", LLONG_MAX);
1064 int64_t res;
1065 int err;
1067 err = qemu_strtoll(str, NULL, 0, &res);
1069 g_assert_cmpint(err, ==, 0);
1070 g_assert_cmpint(res, ==, LLONG_MAX);
1073 static void test_qemu_strtoull_correct(void)
1075 const char *str = "12345 foo";
1076 char f = 'X';
1077 const char *endptr = &f;
1078 uint64_t res = 999;
1079 int err;
1081 err = qemu_strtoull(str, &endptr, 0, &res);
1083 g_assert_cmpint(err, ==, 0);
1084 g_assert_cmpint(res, ==, 12345);
1085 g_assert(endptr == str + 5);
1088 static void test_qemu_strtoull_null(void)
1090 char f = 'X';
1091 const char *endptr = &f;
1092 uint64_t res = 999;
1093 int err;
1095 err = qemu_strtoull(NULL, &endptr, 0, &res);
1097 g_assert_cmpint(err, ==, -EINVAL);
1098 g_assert(endptr == NULL);
1101 static void test_qemu_strtoull_empty(void)
1103 const char *str = "";
1104 char f = 'X';
1105 const char *endptr = &f;
1106 uint64_t res = 999;
1107 int err;
1109 err = qemu_strtoull(str, &endptr, 0, &res);
1111 g_assert_cmpint(err, ==, -EINVAL);
1114 static void test_qemu_strtoull_whitespace(void)
1116 const char *str = " \t ";
1117 char f = 'X';
1118 const char *endptr = &f;
1119 uint64_t res = 999;
1120 int err;
1122 err = qemu_strtoull(str, &endptr, 0, &res);
1124 g_assert_cmpint(err, ==, -EINVAL);
1127 static void test_qemu_strtoull_invalid(void)
1129 const char *str = " xxxx \t abc";
1130 char f = 'X';
1131 const char *endptr = &f;
1132 uint64_t res = 999;
1133 int err;
1135 err = qemu_strtoull(str, &endptr, 0, &res);
1137 g_assert_cmpint(err, ==, -EINVAL);
1140 static void test_qemu_strtoull_trailing(void)
1142 const char *str = "123xxx";
1143 char f = 'X';
1144 const char *endptr = &f;
1145 uint64_t res = 999;
1146 int err;
1148 err = qemu_strtoull(str, &endptr, 0, &res);
1150 g_assert_cmpint(err, ==, 0);
1151 g_assert_cmpint(res, ==, 123);
1152 g_assert(endptr == str + 3);
1155 static void test_qemu_strtoull_octal(void)
1157 const char *str = "0123";
1158 char f = 'X';
1159 const char *endptr = &f;
1160 uint64_t res = 999;
1161 int err;
1163 err = qemu_strtoull(str, &endptr, 8, &res);
1165 g_assert_cmpint(err, ==, 0);
1166 g_assert_cmpint(res, ==, 0123);
1167 g_assert(endptr == str + strlen(str));
1169 endptr = &f;
1170 res = 999;
1171 err = qemu_strtoull(str, &endptr, 0, &res);
1173 g_assert_cmpint(err, ==, 0);
1174 g_assert_cmpint(res, ==, 0123);
1175 g_assert(endptr == str + strlen(str));
1178 static void test_qemu_strtoull_decimal(void)
1180 const char *str = "0123";
1181 char f = 'X';
1182 const char *endptr = &f;
1183 uint64_t res = 999;
1184 int err;
1186 err = qemu_strtoull(str, &endptr, 10, &res);
1188 g_assert_cmpint(err, ==, 0);
1189 g_assert_cmpint(res, ==, 123);
1190 g_assert(endptr == str + strlen(str));
1192 str = "123";
1193 endptr = &f;
1194 res = 999;
1195 err = qemu_strtoull(str, &endptr, 0, &res);
1197 g_assert_cmpint(err, ==, 0);
1198 g_assert_cmpint(res, ==, 123);
1199 g_assert(endptr == str + strlen(str));
1202 static void test_qemu_strtoull_hex(void)
1204 const char *str = "0123";
1205 char f = 'X';
1206 const char *endptr = &f;
1207 uint64_t res = 999;
1208 int err;
1210 err = qemu_strtoull(str, &endptr, 16, &res);
1212 g_assert_cmpint(err, ==, 0);
1213 g_assert_cmpint(res, ==, 0x123);
1214 g_assert(endptr == str + strlen(str));
1216 str = "0x123";
1217 endptr = &f;
1218 res = 999;
1219 err = qemu_strtoull(str, &endptr, 0, &res);
1221 g_assert_cmpint(err, ==, 0);
1222 g_assert_cmpint(res, ==, 0x123);
1223 g_assert(endptr == str + strlen(str));
1226 static void test_qemu_strtoull_max(void)
1228 const char *str = g_strdup_printf("%llu", ULLONG_MAX);
1229 char f = 'X';
1230 const char *endptr = &f;
1231 uint64_t res = 999;
1232 int err;
1234 err = qemu_strtoull(str, &endptr, 0, &res);
1236 g_assert_cmpint(err, ==, 0);
1237 g_assert_cmpint(res, ==, ULLONG_MAX);
1238 g_assert(endptr == str + strlen(str));
1241 static void test_qemu_strtoull_overflow(void)
1243 const char *str = "99999999999999999999999999999999999999999999";
1244 char f = 'X';
1245 const char *endptr = &f;
1246 uint64_t res = 999;
1247 int err;
1249 err = qemu_strtoull(str, &endptr, 0, &res);
1251 g_assert_cmpint(err, ==, -ERANGE);
1252 g_assert_cmpint(res, ==, ULLONG_MAX);
1253 g_assert(endptr == str + strlen(str));
1256 static void test_qemu_strtoull_underflow(void)
1258 const char *str = "-99999999999999999999999999999999999999999999";
1259 char f = 'X';
1260 const char *endptr = &f;
1261 uint64_t res = 999;
1262 int err;
1264 err = qemu_strtoull(str, &endptr, 0, &res);
1266 g_assert_cmpint(err, ==, -ERANGE);
1267 g_assert_cmpint(res, ==, -1);
1268 g_assert(endptr == str + strlen(str));
1271 static void test_qemu_strtoull_negative(void)
1273 const char *str = " \t -321";
1274 char f = 'X';
1275 const char *endptr = &f;
1276 uint64_t res = 999;
1277 int err;
1279 err = qemu_strtoull(str, &endptr, 0, &res);
1281 g_assert_cmpint(err, ==, 0);
1282 g_assert_cmpint(res, ==, -321);
1283 g_assert(endptr == str + strlen(str));
1286 static void test_qemu_strtoull_full_correct(void)
1288 const char *str = "18446744073709551614";
1289 uint64_t res = 999;
1290 int err;
1292 err = qemu_strtoull(str, NULL, 0, &res);
1294 g_assert_cmpint(err, ==, 0);
1295 g_assert_cmpint(res, ==, 18446744073709551614LLU);
1298 static void test_qemu_strtoull_full_null(void)
1300 uint64_t res = 999;
1301 int err;
1303 err = qemu_strtoull(NULL, NULL, 0, &res);
1305 g_assert_cmpint(err, ==, -EINVAL);
1308 static void test_qemu_strtoull_full_empty(void)
1310 const char *str = "";
1311 uint64_t res = 999;
1312 int err;
1314 err = qemu_strtoull(str, NULL, 0, &res);
1316 g_assert_cmpint(err, ==, -EINVAL);
1319 static void test_qemu_strtoull_full_negative(void)
1321 const char *str = " \t -321";
1322 uint64_t res = 999;
1323 int err;
1325 err = qemu_strtoull(str, NULL, 0, &res);
1327 g_assert_cmpint(err, ==, 0);
1328 g_assert_cmpint(res, ==, 18446744073709551295LLU);
1331 static void test_qemu_strtoull_full_trailing(void)
1333 const char *str = "18446744073709551614xxxxxx";
1334 uint64_t res = 999;
1335 int err;
1337 err = qemu_strtoull(str, NULL, 0, &res);
1339 g_assert_cmpint(err, ==, -EINVAL);
1342 static void test_qemu_strtoull_full_max(void)
1344 const char *str = g_strdup_printf("%lld", ULLONG_MAX);
1345 uint64_t res = 999;
1346 int err;
1348 err = qemu_strtoull(str, NULL, 0, &res);
1350 g_assert_cmpint(err, ==, 0);
1351 g_assert_cmpint(res, ==, ULLONG_MAX);
1354 static void test_qemu_strtosz_simple(void)
1356 const char *str = "12345M";
1357 char *endptr = NULL;
1358 int64_t res;
1360 res = qemu_strtosz(str, &endptr);
1361 g_assert_cmpint(res, ==, 12345 * M_BYTE);
1362 g_assert(endptr == str + 6);
1364 res = qemu_strtosz(str, NULL);
1365 g_assert_cmpint(res, ==, 12345 * M_BYTE);
1368 static void test_qemu_strtosz_units(void)
1370 const char *none = "1";
1371 const char *b = "1B";
1372 const char *k = "1K";
1373 const char *m = "1M";
1374 const char *g = "1G";
1375 const char *t = "1T";
1376 const char *p = "1P";
1377 const char *e = "1E";
1378 int64_t res;
1380 /* default is M */
1381 res = qemu_strtosz(none, NULL);
1382 g_assert_cmpint(res, ==, M_BYTE);
1384 res = qemu_strtosz(b, NULL);
1385 g_assert_cmpint(res, ==, 1);
1387 res = qemu_strtosz(k, NULL);
1388 g_assert_cmpint(res, ==, K_BYTE);
1390 res = qemu_strtosz(m, NULL);
1391 g_assert_cmpint(res, ==, M_BYTE);
1393 res = qemu_strtosz(g, NULL);
1394 g_assert_cmpint(res, ==, G_BYTE);
1396 res = qemu_strtosz(t, NULL);
1397 g_assert_cmpint(res, ==, T_BYTE);
1399 res = qemu_strtosz(p, NULL);
1400 g_assert_cmpint(res, ==, P_BYTE);
1402 res = qemu_strtosz(e, NULL);
1403 g_assert_cmpint(res, ==, E_BYTE);
1406 static void test_qemu_strtosz_float(void)
1408 const char *str = "12.345M";
1409 int64_t res;
1411 res = qemu_strtosz(str, NULL);
1412 g_assert_cmpint(res, ==, 12.345 * M_BYTE);
1415 static void test_qemu_strtosz_erange(void)
1417 const char *str = "10E";
1418 int64_t res;
1420 res = qemu_strtosz(str, NULL);
1421 g_assert_cmpint(res, ==, -ERANGE);
1424 static void test_qemu_strtosz_suffix_unit(void)
1426 const char *str = "12345";
1427 int64_t res;
1429 res = qemu_strtosz_suffix_unit(str, NULL,
1430 QEMU_STRTOSZ_DEFSUFFIX_KB, 1000);
1431 g_assert_cmpint(res, ==, 12345000);
1434 int main(int argc, char **argv)
1436 g_test_init(&argc, &argv, NULL);
1438 g_test_add_func("/cutils/parse_uint/null", test_parse_uint_null);
1439 g_test_add_func("/cutils/parse_uint/empty", test_parse_uint_empty);
1440 g_test_add_func("/cutils/parse_uint/whitespace",
1441 test_parse_uint_whitespace);
1442 g_test_add_func("/cutils/parse_uint/invalid", test_parse_uint_invalid);
1443 g_test_add_func("/cutils/parse_uint/trailing", test_parse_uint_trailing);
1444 g_test_add_func("/cutils/parse_uint/correct", test_parse_uint_correct);
1445 g_test_add_func("/cutils/parse_uint/octal", test_parse_uint_octal);
1446 g_test_add_func("/cutils/parse_uint/decimal", test_parse_uint_decimal);
1447 g_test_add_func("/cutils/parse_uint/llong_max", test_parse_uint_llong_max);
1448 g_test_add_func("/cutils/parse_uint/overflow", test_parse_uint_overflow);
1449 g_test_add_func("/cutils/parse_uint/negative", test_parse_uint_negative);
1450 g_test_add_func("/cutils/parse_uint_full/trailing",
1451 test_parse_uint_full_trailing);
1452 g_test_add_func("/cutils/parse_uint_full/correct",
1453 test_parse_uint_full_correct);
1455 /* qemu_strtol() tests */
1456 g_test_add_func("/cutils/qemu_strtol/correct", test_qemu_strtol_correct);
1457 g_test_add_func("/cutils/qemu_strtol/null", test_qemu_strtol_null);
1458 g_test_add_func("/cutils/qemu_strtol/empty", test_qemu_strtol_empty);
1459 g_test_add_func("/cutils/qemu_strtol/whitespace",
1460 test_qemu_strtol_whitespace);
1461 g_test_add_func("/cutils/qemu_strtol/invalid", test_qemu_strtol_invalid);
1462 g_test_add_func("/cutils/qemu_strtol/trailing", test_qemu_strtol_trailing);
1463 g_test_add_func("/cutils/qemu_strtol/octal", test_qemu_strtol_octal);
1464 g_test_add_func("/cutils/qemu_strtol/decimal", test_qemu_strtol_decimal);
1465 g_test_add_func("/cutils/qemu_strtol/hex", test_qemu_strtol_hex);
1466 g_test_add_func("/cutils/qemu_strtol/max", test_qemu_strtol_max);
1467 g_test_add_func("/cutils/qemu_strtol/overflow", test_qemu_strtol_overflow);
1468 g_test_add_func("/cutils/qemu_strtol/underflow",
1469 test_qemu_strtol_underflow);
1470 g_test_add_func("/cutils/qemu_strtol/negative", test_qemu_strtol_negative);
1471 g_test_add_func("/cutils/qemu_strtol_full/correct",
1472 test_qemu_strtol_full_correct);
1473 g_test_add_func("/cutils/qemu_strtol_full/null",
1474 test_qemu_strtol_full_null);
1475 g_test_add_func("/cutils/qemu_strtol_full/empty",
1476 test_qemu_strtol_full_empty);
1477 g_test_add_func("/cutils/qemu_strtol_full/negative",
1478 test_qemu_strtol_full_negative);
1479 g_test_add_func("/cutils/qemu_strtol_full/trailing",
1480 test_qemu_strtol_full_trailing);
1481 g_test_add_func("/cutils/qemu_strtol_full/max",
1482 test_qemu_strtol_full_max);
1484 /* qemu_strtoul() tests */
1485 g_test_add_func("/cutils/qemu_strtoul/correct", test_qemu_strtoul_correct);
1486 g_test_add_func("/cutils/qemu_strtoul/null", test_qemu_strtoul_null);
1487 g_test_add_func("/cutils/qemu_strtoul/empty", test_qemu_strtoul_empty);
1488 g_test_add_func("/cutils/qemu_strtoul/whitespace",
1489 test_qemu_strtoul_whitespace);
1490 g_test_add_func("/cutils/qemu_strtoul/invalid", test_qemu_strtoul_invalid);
1491 g_test_add_func("/cutils/qemu_strtoul/trailing",
1492 test_qemu_strtoul_trailing);
1493 g_test_add_func("/cutils/qemu_strtoul/octal", test_qemu_strtoul_octal);
1494 g_test_add_func("/cutils/qemu_strtoul/decimal", test_qemu_strtoul_decimal);
1495 g_test_add_func("/cutils/qemu_strtoul/hex", test_qemu_strtoul_hex);
1496 g_test_add_func("/cutils/qemu_strtoul/max", test_qemu_strtoul_max);
1497 g_test_add_func("/cutils/qemu_strtoul/overflow",
1498 test_qemu_strtoul_overflow);
1499 g_test_add_func("/cutils/qemu_strtoul/underflow",
1500 test_qemu_strtoul_underflow);
1501 g_test_add_func("/cutils/qemu_strtoul/negative",
1502 test_qemu_strtoul_negative);
1503 g_test_add_func("/cutils/qemu_strtoul_full/correct",
1504 test_qemu_strtoul_full_correct);
1505 g_test_add_func("/cutils/qemu_strtoul_full/null",
1506 test_qemu_strtoul_full_null);
1507 g_test_add_func("/cutils/qemu_strtoul_full/empty",
1508 test_qemu_strtoul_full_empty);
1509 g_test_add_func("/cutils/qemu_strtoul_full/negative",
1510 test_qemu_strtoul_full_negative);
1511 g_test_add_func("/cutils/qemu_strtoul_full/trailing",
1512 test_qemu_strtoul_full_trailing);
1513 g_test_add_func("/cutils/qemu_strtoul_full/max",
1514 test_qemu_strtoul_full_max);
1516 /* qemu_strtoll() tests */
1517 g_test_add_func("/cutils/qemu_strtoll/correct", test_qemu_strtoll_correct);
1518 g_test_add_func("/cutils/qemu_strtoll/null", test_qemu_strtoll_null);
1519 g_test_add_func("/cutils/qemu_strtoll/empty", test_qemu_strtoll_empty);
1520 g_test_add_func("/cutils/qemu_strtoll/whitespace",
1521 test_qemu_strtoll_whitespace);
1522 g_test_add_func("/cutils/qemu_strtoll/invalid", test_qemu_strtoll_invalid);
1523 g_test_add_func("/cutils/qemu_strtoll/trailing",
1524 test_qemu_strtoll_trailing);
1525 g_test_add_func("/cutils/qemu_strtoll/octal", test_qemu_strtoll_octal);
1526 g_test_add_func("/cutils/qemu_strtoll/decimal", test_qemu_strtoll_decimal);
1527 g_test_add_func("/cutils/qemu_strtoll/hex", test_qemu_strtoll_hex);
1528 g_test_add_func("/cutils/qemu_strtoll/max", test_qemu_strtoll_max);
1529 g_test_add_func("/cutils/qemu_strtoll/overflow",
1530 test_qemu_strtoll_overflow);
1531 g_test_add_func("/cutils/qemu_strtoll/underflow",
1532 test_qemu_strtoll_underflow);
1533 g_test_add_func("/cutils/qemu_strtoll/negative",
1534 test_qemu_strtoll_negative);
1535 g_test_add_func("/cutils/qemu_strtoll_full/correct",
1536 test_qemu_strtoll_full_correct);
1537 g_test_add_func("/cutils/qemu_strtoll_full/null",
1538 test_qemu_strtoll_full_null);
1539 g_test_add_func("/cutils/qemu_strtoll_full/empty",
1540 test_qemu_strtoll_full_empty);
1541 g_test_add_func("/cutils/qemu_strtoll_full/negative",
1542 test_qemu_strtoll_full_negative);
1543 g_test_add_func("/cutils/qemu_strtoll_full/trailing",
1544 test_qemu_strtoll_full_trailing);
1545 g_test_add_func("/cutils/qemu_strtoll_full/max",
1546 test_qemu_strtoll_full_max);
1548 /* qemu_strtoull() tests */
1549 g_test_add_func("/cutils/qemu_strtoull/correct",
1550 test_qemu_strtoull_correct);
1551 g_test_add_func("/cutils/qemu_strtoull/null",
1552 test_qemu_strtoull_null);
1553 g_test_add_func("/cutils/qemu_strtoull/empty", test_qemu_strtoull_empty);
1554 g_test_add_func("/cutils/qemu_strtoull/whitespace",
1555 test_qemu_strtoull_whitespace);
1556 g_test_add_func("/cutils/qemu_strtoull/invalid",
1557 test_qemu_strtoull_invalid);
1558 g_test_add_func("/cutils/qemu_strtoull/trailing",
1559 test_qemu_strtoull_trailing);
1560 g_test_add_func("/cutils/qemu_strtoull/octal", test_qemu_strtoull_octal);
1561 g_test_add_func("/cutils/qemu_strtoull/decimal",
1562 test_qemu_strtoull_decimal);
1563 g_test_add_func("/cutils/qemu_strtoull/hex", test_qemu_strtoull_hex);
1564 g_test_add_func("/cutils/qemu_strtoull/max", test_qemu_strtoull_max);
1565 g_test_add_func("/cutils/qemu_strtoull/overflow",
1566 test_qemu_strtoull_overflow);
1567 g_test_add_func("/cutils/qemu_strtoull/underflow",
1568 test_qemu_strtoull_underflow);
1569 g_test_add_func("/cutils/qemu_strtoull/negative",
1570 test_qemu_strtoull_negative);
1571 g_test_add_func("/cutils/qemu_strtoull_full/correct",
1572 test_qemu_strtoull_full_correct);
1573 g_test_add_func("/cutils/qemu_strtoull_full/null",
1574 test_qemu_strtoull_full_null);
1575 g_test_add_func("/cutils/qemu_strtoull_full/empty",
1576 test_qemu_strtoull_full_empty);
1577 g_test_add_func("/cutils/qemu_strtoull_full/negative",
1578 test_qemu_strtoull_full_negative);
1579 g_test_add_func("/cutils/qemu_strtoull_full/trailing",
1580 test_qemu_strtoull_full_trailing);
1581 g_test_add_func("/cutils/qemu_strtoull_full/max",
1582 test_qemu_strtoull_full_max);
1584 g_test_add_func("/cutils/strtosz/simple",
1585 test_qemu_strtosz_simple);
1586 g_test_add_func("/cutils/strtosz/units",
1587 test_qemu_strtosz_units);
1588 g_test_add_func("/cutils/strtosz/float",
1589 test_qemu_strtosz_float);
1590 g_test_add_func("/cutils/strtosz/erange",
1591 test_qemu_strtosz_erange);
1592 g_test_add_func("/cutils/strtosz/suffix-unit",
1593 test_qemu_strtosz_suffix_unit);
1595 return g_test_run();