+ },
+};
+
+typedef struct z_data_st {
+ size_t value;
+ const char *format;
+ const char *expected;
+} z_data;
+
+static z_data zu_data[] = {
+ { SIZE_MAX, "%zu", (sizeof(size_t) == 4 ? "4294967295"
+ : sizeof(size_t) == 8 ? "18446744073709551615"
+ : "") },
+ /*
+ * in 2-complement, the unsigned number divided by two plus one becomes the
+ * smallest possible negative signed number of the corresponding type
+ */
+ { SIZE_MAX / 2 + 1, "%zi", (sizeof(size_t) == 4 ? "-2147483648"
+ : sizeof(size_t) == 8 ? "-9223372036854775808"
+ : "") },
+ { 0, "%zu", "0" },
+ { 0, "%zi", "0" },
+};
+
+static int test_zu(int i)
+{
+ char bio_buf[80];
+ const z_data *data = &zu_data[i];
+
+ BIO_snprintf(bio_buf, sizeof(bio_buf) - 1, data->format, data->value);
+ if (!TEST_str_eq(bio_buf, data->expected))
+ return 0;
+ return 1;
+}
+
+typedef struct j_data_st {
+ uint64_t value;
+ const char *format;
+ const char *expected;
+} j_data;
+
+static j_data jf_data[] = {
+ { 0xffffffffffffffffU, "%ju", "18446744073709551615" },
+ { 0xffffffffffffffffU, "%jx", "ffffffffffffffff" },
+ { 0x8000000000000000U, "%ju", "9223372036854775808" },
+ /*
+ * These tests imply two's-complement, but it's the only binary
+ * representation we support, see test/sanitytest.c...
+ */
+ { 0x8000000000000000U, "%ji", "-9223372036854775808" },
+};
+
+static int test_j(int i)
+{
+ const j_data *data = &jf_data[i];
+ char bio_buf[80];
+
+ BIO_snprintf(bio_buf, sizeof(bio_buf) - 1, data->format, data->value);
+ if (!TEST_str_eq(bio_buf, data->expected))
+ return 0;
+ return 1;
+}
+
+
+/* Precision and width. */
+typedef struct pw_st {
+ int p;
+ const char *w;
+} pw;
+
+static pw pw_params[] = {
+ { 4, "" },
+ { 5, "" },
+ { 4, "12" },
+ { 5, "12" },
+ { 0, "" },
+ { -1, "" },
+ { 4, "08" }