tests/ansi: check %h and %hh printf length modifiers
@@ -113,6 +113,21 @@ int main() {
sprintf(buf, "%#o", 0);
assert(!strcmp(buf, "0"));
+ // Test 'd' with different size mods to see
+ // if they work
+ sprintf(buf, "%d", 12);
+ assert(!strcmp(buf, "12"));
+ sprintf(buf, "%ld", 12);
+ assert(!strcmp(buf, "12"));
+ sprintf(buf, "%lld", 12);
+ assert(!strcmp(buf, "12"));
+ sprintf(buf, "%zd", 12);
+ assert(!strcmp(buf, "12"));
+ sprintf(buf, "%hd", 12);
+ assert(!strcmp(buf, "12"));
+ sprintf(buf, "%hhd", 12);
+ assert(!strcmp(buf, "12"));
+
// Test 'x' with different size mods to see
// if they work
sprintf(buf, "%x", 12);
@@ -123,6 +138,10 @@ int main() {
assert(!strcmp(buf, "c"));
sprintf(buf, "%zx", 12);
assert(!strcmp(buf, "c"));
+ sprintf(buf, "%hx", 12);
+ assert(!strcmp(buf, "c"));
+ sprintf(buf, "%hhx", 12);
+ assert(!strcmp(buf, "c"));
// Test 'X' with different size mods to see
// if they work
@@ -134,6 +153,10 @@ int main() {
assert(!strcmp(buf, "C"));
sprintf(buf, "%zX", 12);
assert(!strcmp(buf, "C"));
+ sprintf(buf, "%hX", 12);
+ assert(!strcmp(buf, "C"));
+ sprintf(buf, "%hhX", 12);
+ assert(!strcmp(buf, "C"));
// Test 'o' with different size mods to see
// if they work
@@ -145,6 +168,10 @@ int main() {
assert(!strcmp(buf, "14"));
sprintf(buf, "%zo", 12);
assert(!strcmp(buf, "14"));
+ sprintf(buf, "%ho", 12);
+ assert(!strcmp(buf, "14"));
+ sprintf(buf, "%hho", 12);
+ assert(!strcmp(buf, "14"));
// Test %n$ syntax.
sprintf(buf, "%1$d", 12);
