+ if (justprint)
+ printf(" },\n");
+ return ret;
+}
+
+static int test_fp(int i)
+{
+ int t = 0, r;
+ const double frac = 2.0 / 3.0;
+ const pw *pwp = &pw_params[i];
+
+ if (justprint)
+ printf(" {\n");
+ r = TEST_true(dofptest(i, t++, 0.0, pwp->w, pwp->p))
+ && TEST_true(dofptest(i, t++, 0.67, pwp->w, pwp->p))
+ && TEST_true(dofptest(i, t++, frac, pwp->w, pwp->p))
+ && TEST_true(dofptest(i, t++, frac / 1000, pwp->w, pwp->p))
+ && TEST_true(dofptest(i, t++, frac / 10000, pwp->w, pwp->p))
+ && TEST_true(dofptest(i, t++, 6.0 + frac, pwp->w, pwp->p))
+ && TEST_true(dofptest(i, t++, 66.0 + frac, pwp->w, pwp->p))
+ && TEST_true(dofptest(i, t++, 666.0 + frac, pwp->w, pwp->p))
+ && TEST_true(dofptest(i, t++, 6666.0 + frac, pwp->w, pwp->p))
+ && TEST_true(dofptest(i, t++, 66666.0 + frac, pwp->w, pwp->p));
+ if (justprint)
+ printf(" },\n");
+ return r;
+}
+
+static int test_big(void)
+{
+ char buf[80];
+
+ /* Test excessively big number. Should fail */
+ if (!TEST_int_eq(BIO_snprintf(buf, sizeof(buf),
+ "%f\n", 2 * (double)ULONG_MAX), -1))
+ return 0;
+ return 1;
+}
+
+
+int setup_tests(void)
+{
+ justprint = test_has_option("-expected");
+
+ ADD_TEST(test_big);
+ ADD_ALL_TESTS(test_fp, nelem(pw_params));
+ ADD_ALL_TESTS(test_zu, nelem(zu_data));
+ ADD_ALL_TESTS(test_j, nelem(jf_data));
+ return 1;
+}
+
+/*
+ * Replace testutil output routines. We do this to eliminate possible sources
+ * of BIO error
+ */
+void test_open_streams(void)
+{
+}
+
+void test_close_streams(void)
+{
+}
+
+/*
+ * This works out as long as caller doesn't use any "fancy" formats.
+ * But we are caller's caller, and test_str_eq is the only one called,
+ * and it uses only "%s", which is not "fancy"...
+ */
+int test_vprintf_stdout(const char *fmt, va_list ap)
+{
+ return vfprintf(stdout, fmt, ap);