summaryrefslogtreecommitdiff
path: root/tests/unistdio/test-u16-asnprintf1.h
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2024-10-20 15:21:43 +0200
committerJörg Frings-Fürst <debian@jff.email>2024-10-20 15:21:43 +0200
commit4682deeb62247d34de87f8e777f99e2d337fd377 (patch)
tree5bd5b5605b5f3a4b3c8ea7468c34c23094afdef4 /tests/unistdio/test-u16-asnprintf1.h
parent00893e79fc62966067af1a106567db96bd170338 (diff)
New upstream version 1.3upstream/1.3upstream
Diffstat (limited to 'tests/unistdio/test-u16-asnprintf1.h')
-rw-r--r--tests/unistdio/test-u16-asnprintf1.h55
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/unistdio/test-u16-asnprintf1.h b/tests/unistdio/test-u16-asnprintf1.h
index 4ec31a43..2b1a9ab3 100644
--- a/tests/unistdio/test-u16-asnprintf1.h
+++ b/tests/unistdio/test-u16-asnprintf1.h
@@ -57,4 +57,59 @@ test_function (uint16_t * (*my_asnprintf) (uint16_t *, size_t *, const char *, .
if (result != buf)
free (result);
}
+
+ /* Verify that u16_[v]asnprintf() rejects a width > 2 GiB, < 4 GiB. */
+ {
+ size_t length;
+ uint16_t *s = my_asnprintf (NULL, &length, "x%03000000000dy\n", -17);
+ ASSERT (s == NULL);
+ ASSERT (errno == EOVERFLOW);
+ }
+ {
+ static const uint16_t arg[] = { '@', 0 };
+ size_t length;
+ uint16_t *s = my_asnprintf (NULL, &length, "x%03000000000lUy\n", arg);
+ ASSERT (s == NULL);
+ ASSERT (errno == EOVERFLOW);
+ }
+
+ /* Verify that u16_[v]asnprintf() rejects a width > 4 GiB. */
+ {
+ size_t length;
+ uint16_t *s =
+ my_asnprintf (NULL, &length,
+ "x%04294967306dy\n", /* 2^32 + 10 */
+ -17);
+ ASSERT (s == NULL);
+ ASSERT (errno == EOVERFLOW);
+ }
+ {
+ static const uint16_t arg[] = { '@', 0 };
+ size_t length;
+ uint16_t *s =
+ my_asnprintf (NULL, &length,
+ "x%04294967306lUy\n", /* 2^32 + 10 */
+ arg);
+ ASSERT (s == NULL);
+ ASSERT (errno == EOVERFLOW);
+ }
+ {
+ size_t length;
+ uint16_t *s =
+ my_asnprintf (NULL, &length,
+ "x%018446744073709551626dy\n", /* 2^64 + 10 */
+ -17);
+ ASSERT (s == NULL);
+ ASSERT (errno == EOVERFLOW);
+ }
+ {
+ static const uint16_t arg[] = { '@', 0 };
+ size_t length;
+ uint16_t *s =
+ my_asnprintf (NULL, &length,
+ "x%018446744073709551626lUy\n", /* 2^64 + 10 */
+ arg);
+ ASSERT (s == NULL);
+ ASSERT (errno == EOVERFLOW);
+ }
}