-
-
Notifications
You must be signed in to change notification settings - Fork 66
Open
Description
These checks should be added to the tests.
NPF is already conformant.
See the standard, about "hh":
Specifies that a following b, d, i, o, u, x, or X conversion specifier applies to a signed char or unsigned char argument (the argument will have been promoted according to the integer promotions, but its value shall be converted to signed char or unsigned char before printing);
Nothing prevents the caller from actually passing in an int or unsigned int, even if the size modifier is "hh" or "h"; so, it is up to the library to cast the value appropriately, to fit it into the proper type.
I'm only providing tests for "%i" and "%u" (besides "%c"), since all other integer specifiers should share the same code paths, as long as argument-fetching is concerned.
#if CHAR_BIT != 8
#error Unsupported CHAR_BIT
#endif
require_conform("a", "%c", (int)('a' + (UINT_MAX << 8)));
require_conform("0", "%hhi", INT_MIN);
require_conform("-1", "%hhi", INT_MAX);
require_conform("0", "%hhu", INT_MIN);
require_conform("255", "%hhu", UINT_MAX);
#if USHRT_MAX <= 0xFFu
require_conform("0", "%hi", INT_MIN);
require_conform("-1", "%hi", INT_MAX);
require_conform("0", "%hu", INT_MIN);
require_conform("255", "%hu", UINT_MAX);
#elif USHRT_MAX <= 0xFFFFu
require_conform("0", "%hi", INT_MIN);
require_conform("-1", "%hi", INT_MAX);
require_conform("0", "%hu", INT_MIN);
require_conform("65535", "%hu", UINT_MAX);
#else
#error Unsupported sizeof(short)
#endif
Metadata
Metadata
Assignees
Labels
No labels