summaryrefslogtreecommitdiff
path: root/tests/unistdio/test-ulc-asnprintf1.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unistdio/test-ulc-asnprintf1.h')
-rw-r--r--tests/unistdio/test-ulc-asnprintf1.h55
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/unistdio/test-ulc-asnprintf1.h b/tests/unistdio/test-ulc-asnprintf1.h
index 9e11f314..8ede282f 100644
--- a/tests/unistdio/test-ulc-asnprintf1.h
+++ b/tests/unistdio/test-ulc-asnprintf1.h
@@ -51,4 +51,59 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
if (result != buf)
free (result);
}
+
+ /* Verify that ulc_[v]asnprintf() rejects a width > 2 GiB, < 4 GiB. */
+ {
+ size_t length;
+ char *s = my_asnprintf (NULL, &length, "x%03000000000dy\n", -17);
+ ASSERT (s == NULL);
+ ASSERT (errno == EOVERFLOW);
+ }
+ {
+ static const uint8_t arg[] = { '@', 0 };
+ size_t length;
+ char *s = my_asnprintf (NULL, &length, "x%03000000000Uy\n", arg);
+ ASSERT (s == NULL);
+ ASSERT (errno == EOVERFLOW);
+ }
+
+ /* Verify that ulc_[v]asnprintf() rejects a width > 4 GiB. */
+ {
+ size_t length;
+ char *s =
+ my_asnprintf (NULL, &length,
+ "x%04294967306dy\n", /* 2^32 + 10 */
+ -17);
+ ASSERT (s == NULL);
+ ASSERT (errno == EOVERFLOW);
+ }
+ {
+ static const uint8_t arg[] = { '@', 0 };
+ size_t length;
+ char *s =
+ my_asnprintf (NULL, &length,
+ "x%04294967306Uy\n", /* 2^32 + 10 */
+ arg);
+ ASSERT (s == NULL);
+ ASSERT (errno == EOVERFLOW);
+ }
+ {
+ size_t length;
+ char *s =
+ my_asnprintf (NULL, &length,
+ "x%018446744073709551626dy\n", /* 2^64 + 10 */
+ -17);
+ ASSERT (s == NULL);
+ ASSERT (errno == EOVERFLOW);
+ }
+ {
+ static const uint8_t arg[] = { '@', 0 };
+ size_t length;
+ char *s =
+ my_asnprintf (NULL, &length,
+ "x%018446744073709551626Uy\n", /* 2^64 + 10 */
+ arg);
+ ASSERT (s == NULL);
+ ASSERT (errno == EOVERFLOW);
+ }
}