free (result);
}
+ { /* Precision with no rounding. */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%.2f %d", 999.951, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "999.95 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+
+ { /* Precision with rounding. */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%.2f %d", 999.996, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "1000.00 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+
{ /* A positive number. */
size_t length;
char *result =
free (result);
}
+ { /* Precision with no rounding. */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%.2Lf %d", 999.951L, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "999.95 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+
+ { /* Precision with rounding. */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%.2Lf %d", 999.996L, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "1000.00 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+
/* Test the support of the %F format directive. */
{ /* A positive number. */
free (result);
}
+ { /* Precision with no rounding. */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%.2F %d", 999.951, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "999.95 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+
+ { /* Precision with rounding. */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%.2F %d", 999.996, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "1000.00 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+
{ /* A positive number. */
size_t length;
char *result =
free (result);
}
+ { /* Precision with no rounding. */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%.2LF %d", 999.951L, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "999.95 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+
+ { /* Precision with rounding. */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%.2LF %d", 999.996L, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "1000.00 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+
/* Test the support of the %e format directive. */
{ /* A positive number. */
free (result);
}
+ { /* Precision with no rounding. */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%.4e %d", 999.951, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "9.9995e+02 33") == 0
+ || strcmp (result, "9.9995e+002 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+
+ { /* Precision with rounding. */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%.4e %d", 999.996, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "1.0000e+03 33") == 0
+ || strcmp (result, "1.0000e+003 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+
{ /* A positive number. */
size_t length;
char *result =
free (result);
}
+ { /* Precision with no rounding. */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%.4Le %d", 999.951L, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "9.9995e+02 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+
+ { /* Precision with rounding. */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%.4Le %d", 999.996L, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "1.0000e+03 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+
/* Test the support of the %g format directive. */
{ /* A positive number. */
free (result);
}
+ { /* Precision with no rounding. */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%.5g %d", 999.951, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "999.95 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+
+ { /* Precision with rounding. */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%.5g %d", 999.996, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "1000 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+
{ /* A positive number. */
size_t length;
char *result =
free (result);
}
+ { /* Precision with no rounding. */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%.5Lg %d", 999.951L, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "999.95 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+
+ { /* Precision with rounding. */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%.5Lg %d", 999.996L, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "1000 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+
/* Test the support of the %n format directive. */
{