|
679 | 679 | if (_metadata->passed && _metadata->step < 255) \
|
680 | 680 | _metadata->step++;
|
681 | 681 |
|
| 682 | +#define is_signed_type(var) (!!(((__typeof__(var))(-1)) < (__typeof__(var))1)) |
| 683 | + |
682 | 684 | #define __EXPECT(_expected, _expected_str, _seen, _seen_str, _t, _assert) do { \
|
683 | 685 | /* Avoid multiple evaluation of the cases */ \
|
684 | 686 | __typeof__(_expected) __exp = (_expected); \
|
685 | 687 | __typeof__(_seen) __seen = (_seen); \
|
686 | 688 | if (_assert) __INC_STEP(_metadata); \
|
687 | 689 | if (!(__exp _t __seen)) { \
|
688 |
| - unsigned long long __exp_print = (uintptr_t)__exp; \ |
689 |
| - unsigned long long __seen_print = (uintptr_t)__seen; \ |
690 |
| - __TH_LOG("Expected %s (%llu) %s %s (%llu)", \ |
691 |
| - _expected_str, __exp_print, #_t, \ |
692 |
| - _seen_str, __seen_print); \ |
| 690 | + /* Report with actual signedness to avoid weird output. */ \ |
| 691 | + switch (is_signed_type(__exp) * 2 + is_signed_type(__seen)) { \ |
| 692 | + case 0: { \ |
| 693 | + unsigned long long __exp_print = (uintptr_t)__exp; \ |
| 694 | + unsigned long long __seen_print = (uintptr_t)__seen; \ |
| 695 | + __TH_LOG("Expected %s (%llu) %s %s (%llu)", \ |
| 696 | + _expected_str, __exp_print, #_t, \ |
| 697 | + _seen_str, __seen_print); \ |
| 698 | + break; \ |
| 699 | + } \ |
| 700 | + case 1: { \ |
| 701 | + unsigned long long __exp_print = (uintptr_t)__exp; \ |
| 702 | + long long __seen_print = (intptr_t)__seen; \ |
| 703 | + __TH_LOG("Expected %s (%llu) %s %s (%lld)", \ |
| 704 | + _expected_str, __exp_print, #_t, \ |
| 705 | + _seen_str, __seen_print); \ |
| 706 | + break; \ |
| 707 | + } \ |
| 708 | + case 2: { \ |
| 709 | + long long __exp_print = (intptr_t)__exp; \ |
| 710 | + unsigned long long __seen_print = (uintptr_t)__seen; \ |
| 711 | + __TH_LOG("Expected %s (%lld) %s %s (%llu)", \ |
| 712 | + _expected_str, __exp_print, #_t, \ |
| 713 | + _seen_str, __seen_print); \ |
| 714 | + break; \ |
| 715 | + } \ |
| 716 | + case 3: { \ |
| 717 | + long long __exp_print = (intptr_t)__exp; \ |
| 718 | + long long __seen_print = (intptr_t)__seen; \ |
| 719 | + __TH_LOG("Expected %s (%lld) %s %s (%lld)", \ |
| 720 | + _expected_str, __exp_print, #_t, \ |
| 721 | + _seen_str, __seen_print); \ |
| 722 | + break; \ |
| 723 | + } \ |
| 724 | + } \ |
693 | 725 | _metadata->passed = 0; \
|
694 | 726 | /* Ensure the optional handler is triggered */ \
|
695 | 727 | _metadata->trigger = 1; \
|
|
0 commit comments