diff options
Diffstat (limited to 'tests/test-snprintf-posix.h')
-rw-r--r-- | tests/test-snprintf-posix.h | 1626 |
1 files changed, 813 insertions, 813 deletions
diff --git a/tests/test-snprintf-posix.h b/tests/test-snprintf-posix.h index 262cdda558..24999d3431 100644 --- a/tests/test-snprintf-posix.h +++ b/tests/test-snprintf-posix.h @@ -79,15 +79,15 @@ strisnan (const char *string, size_t start_index, size_t end_index, int uppercas if (start_index < end_index) { if (string[start_index] == '-') - start_index++; + start_index++; if (start_index + 3 <= end_index - && memcmp (string + start_index, uppercase ? "NAN" : "nan", 3) == 0) - { - start_index += 3; - if (start_index == end_index - || (string[start_index] == '(' && string[end_index - 1] == ')')) - return 1; - } + && memcmp (string + start_index, uppercase ? "NAN" : "nan", 3) == 0) + { + start_index += 3; + if (start_index == end_index + || (string[start_index] == '(' && string[end_index - 1] == ')')) + return 1; + } } return 0; } @@ -108,18 +108,18 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) retval = my_snprintf (buf, size, "%d", 12345); ASSERT (retval == 5); if (size < 6) - { - if (size > 0) - { - ASSERT (memcmp (buf, "12345", size - 1) == 0); - ASSERT (buf[size - 1] == '\0'); - } - ASSERT (memcmp (buf + size, "DEADBEEF" + size, 8 - size) == 0); - } + { + if (size > 0) + { + ASSERT (memcmp (buf, "12345", size - 1) == 0); + ASSERT (buf[size - 1] == '\0'); + } + ASSERT (memcmp (buf + size, "DEADBEEF" + size, 8 - size) == 0); + } else - { - ASSERT (memcmp (buf, "12345\0EF", 8) == 0); - } + { + ASSERT (memcmp (buf, "12345\0EF", 8) == 0); + } } /* Test support of size specifiers as in C99. */ @@ -164,9 +164,9 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%a %d", 3.1416015625, 33, 44, 55); ASSERT (strcmp (result, "0x1.922p+1 33") == 0 - || strcmp (result, "0x3.244p+0 33") == 0 - || strcmp (result, "0x6.488p-1 33") == 0 - || strcmp (result, "0xc.91p-2 33") == 0); + || strcmp (result, "0x3.244p+0 33") == 0 + || strcmp (result, "0x6.488p-1 33") == 0 + || strcmp (result, "0xc.91p-2 33") == 0); ASSERT (retval == strlen (result)); } @@ -175,9 +175,9 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%A %d", -3.1416015625, 33, 44, 55); ASSERT (strcmp (result, "-0X1.922P+1 33") == 0 - || strcmp (result, "-0X3.244P+0 33") == 0 - || strcmp (result, "-0X6.488P-1 33") == 0 - || strcmp (result, "-0XC.91P-2 33") == 0); + || strcmp (result, "-0X3.244P+0 33") == 0 + || strcmp (result, "-0X6.488P-1 33") == 0 + || strcmp (result, "-0XC.91P-2 33") == 0); ASSERT (retval == strlen (result)); } @@ -219,8 +219,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%a %d", NaNd (), 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && strisnan (result, 0, strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -229,9 +229,9 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%.0a %d", 1.5, 33, 44, 55); ASSERT (strcmp (result, "0x2p+0 33") == 0 - || strcmp (result, "0x3p-1 33") == 0 - || strcmp (result, "0x6p-2 33") == 0 - || strcmp (result, "0xcp-3 33") == 0); + || strcmp (result, "0x3p-1 33") == 0 + || strcmp (result, "0x6p-2 33") == 0 + || strcmp (result, "0xcp-3 33") == 0); ASSERT (retval == strlen (result)); } @@ -240,9 +240,9 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%.0a %d", 1.51, 33, 44, 55); ASSERT (strcmp (result, "0x2p+0 33") == 0 - || strcmp (result, "0x3p-1 33") == 0 - || strcmp (result, "0x6p-2 33") == 0 - || strcmp (result, "0xcp-3 33") == 0); + || strcmp (result, "0x3p-1 33") == 0 + || strcmp (result, "0x6p-2 33") == 0 + || strcmp (result, "0xcp-3 33") == 0); ASSERT (retval == strlen (result)); } @@ -251,9 +251,9 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%.1a %d", 1.51, 33, 44, 55); ASSERT (strcmp (result, "0x1.8p+0 33") == 0 - || strcmp (result, "0x3.0p-1 33") == 0 - || strcmp (result, "0x6.1p-2 33") == 0 - || strcmp (result, "0xc.1p-3 33") == 0); + || strcmp (result, "0x3.0p-1 33") == 0 + || strcmp (result, "0x6.1p-2 33") == 0 + || strcmp (result, "0xc.1p-3 33") == 0); ASSERT (retval == strlen (result)); } @@ -262,9 +262,9 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%.2a %d", 1.51, 33, 44, 55); ASSERT (strcmp (result, "0x1.83p+0 33") == 0 - || strcmp (result, "0x3.05p-1 33") == 0 - || strcmp (result, "0x6.0ap-2 33") == 0 - || strcmp (result, "0xc.14p-3 33") == 0); + || strcmp (result, "0x3.05p-1 33") == 0 + || strcmp (result, "0x6.0ap-2 33") == 0 + || strcmp (result, "0xc.14p-3 33") == 0); ASSERT (retval == strlen (result)); } @@ -273,9 +273,9 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%.3a %d", 1.51, 33, 44, 55); ASSERT (strcmp (result, "0x1.829p+0 33") == 0 - || strcmp (result, "0x3.052p-1 33") == 0 - || strcmp (result, "0x6.0a4p-2 33") == 0 - || strcmp (result, "0xc.148p-3 33") == 0); + || strcmp (result, "0x3.052p-1 33") == 0 + || strcmp (result, "0x6.0a4p-2 33") == 0 + || strcmp (result, "0xc.148p-3 33") == 0); ASSERT (retval == strlen (result)); } @@ -284,9 +284,9 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%.3a %d", 1.49999, 33, 44, 55); ASSERT (strcmp (result, "0x1.800p+0 33") == 0 - || strcmp (result, "0x3.000p-1 33") == 0 - || strcmp (result, "0x6.000p-2 33") == 0 - || strcmp (result, "0xc.000p-3 33") == 0); + || strcmp (result, "0x3.000p-1 33") == 0 + || strcmp (result, "0x6.000p-2 33") == 0 + || strcmp (result, "0xc.000p-3 33") == 0); ASSERT (retval == strlen (result)); } @@ -296,9 +296,9 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%.1a %d", 1.999, 33, 44, 55); ASSERT (strcmp (result, "0x1.0p+1 33") == 0 - || strcmp (result, "0x2.0p+0 33") == 0 - || strcmp (result, "0x4.0p-1 33") == 0 - || strcmp (result, "0x8.0p-2 33") == 0); + || strcmp (result, "0x2.0p+0 33") == 0 + || strcmp (result, "0x4.0p-1 33") == 0 + || strcmp (result, "0x8.0p-2 33") == 0); ASSERT (retval == strlen (result)); } @@ -307,9 +307,9 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%10a %d", 1.75, 33, 44, 55); ASSERT (strcmp (result, " 0x1.cp+0 33") == 0 - || strcmp (result, " 0x3.8p-1 33") == 0 - || strcmp (result, " 0x7p-2 33") == 0 - || strcmp (result, " 0xep-3 33") == 0); + || strcmp (result, " 0x3.8p-1 33") == 0 + || strcmp (result, " 0x7p-2 33") == 0 + || strcmp (result, " 0xep-3 33") == 0); ASSERT (retval == strlen (result)); } @@ -318,9 +318,9 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%.10a %d", 1.75, 33, 44, 55); ASSERT (strcmp (result, "0x1.c000000000p+0 33") == 0 - || strcmp (result, "0x3.8000000000p-1 33") == 0 - || strcmp (result, "0x7.0000000000p-2 33") == 0 - || strcmp (result, "0xe.0000000000p-3 33") == 0); + || strcmp (result, "0x3.8000000000p-1 33") == 0 + || strcmp (result, "0x7.0000000000p-2 33") == 0 + || strcmp (result, "0xe.0000000000p-3 33") == 0); ASSERT (retval == strlen (result)); } @@ -329,9 +329,9 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%.50a %d", 1.75, 33, 44, 55); ASSERT (strcmp (result, "0x1.c0000000000000000000000000000000000000000000000000p+0 33") == 0 - || strcmp (result, "0x3.80000000000000000000000000000000000000000000000000p-1 33") == 0 - || strcmp (result, "0x7.00000000000000000000000000000000000000000000000000p-2 33") == 0 - || strcmp (result, "0xe.00000000000000000000000000000000000000000000000000p-3 33") == 0); + || strcmp (result, "0x3.80000000000000000000000000000000000000000000000000p-1 33") == 0 + || strcmp (result, "0x7.00000000000000000000000000000000000000000000000000p-2 33") == 0 + || strcmp (result, "0xe.00000000000000000000000000000000000000000000000000p-3 33") == 0); ASSERT (retval == strlen (result)); } @@ -340,9 +340,9 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%-10a %d", 1.75, 33, 44, 55); ASSERT (strcmp (result, "0x1.cp+0 33") == 0 - || strcmp (result, "0x3.8p-1 33") == 0 - || strcmp (result, "0x7p-2 33") == 0 - || strcmp (result, "0xep-3 33") == 0); + || strcmp (result, "0x3.8p-1 33") == 0 + || strcmp (result, "0x7p-2 33") == 0 + || strcmp (result, "0xep-3 33") == 0); ASSERT (retval == strlen (result)); } @@ -351,9 +351,9 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%+a %d", 1.75, 33, 44, 55); ASSERT (strcmp (result, "+0x1.cp+0 33") == 0 - || strcmp (result, "+0x3.8p-1 33") == 0 - || strcmp (result, "+0x7p-2 33") == 0 - || strcmp (result, "+0xep-3 33") == 0); + || strcmp (result, "+0x3.8p-1 33") == 0 + || strcmp (result, "+0x7p-2 33") == 0 + || strcmp (result, "+0xep-3 33") == 0); ASSERT (retval == strlen (result)); } @@ -362,9 +362,9 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "% a %d", 1.75, 33, 44, 55); ASSERT (strcmp (result, " 0x1.cp+0 33") == 0 - || strcmp (result, " 0x3.8p-1 33") == 0 - || strcmp (result, " 0x7p-2 33") == 0 - || strcmp (result, " 0xep-3 33") == 0); + || strcmp (result, " 0x3.8p-1 33") == 0 + || strcmp (result, " 0x7p-2 33") == 0 + || strcmp (result, " 0xep-3 33") == 0); ASSERT (retval == strlen (result)); } @@ -373,9 +373,9 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%#a %d", 1.75, 33, 44, 55); ASSERT (strcmp (result, "0x1.cp+0 33") == 0 - || strcmp (result, "0x3.8p-1 33") == 0 - || strcmp (result, "0x7.p-2 33") == 0 - || strcmp (result, "0xe.p-3 33") == 0); + || strcmp (result, "0x3.8p-1 33") == 0 + || strcmp (result, "0x7.p-2 33") == 0 + || strcmp (result, "0xe.p-3 33") == 0); ASSERT (retval == strlen (result)); } @@ -384,9 +384,9 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%#a %d", 1.0, 33, 44, 55); ASSERT (strcmp (result, "0x1.p+0 33") == 0 - || strcmp (result, "0x2.p-1 33") == 0 - || strcmp (result, "0x4.p-2 33") == 0 - || strcmp (result, "0x8.p-3 33") == 0); + || strcmp (result, "0x2.p-1 33") == 0 + || strcmp (result, "0x4.p-2 33") == 0 + || strcmp (result, "0x8.p-3 33") == 0); ASSERT (retval == strlen (result)); } @@ -395,9 +395,9 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%010a %d", 1.75, 33, 44, 55); ASSERT (strcmp (result, "0x001.cp+0 33") == 0 - || strcmp (result, "0x003.8p-1 33") == 0 - || strcmp (result, "0x00007p-2 33") == 0 - || strcmp (result, "0x0000ep-3 33") == 0); + || strcmp (result, "0x003.8p-1 33") == 0 + || strcmp (result, "0x00007p-2 33") == 0 + || strcmp (result, "0x0000ep-3 33") == 0); ASSERT (retval == strlen (result)); } @@ -418,8 +418,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) /* "0000000nan 33" is not a valid result; see <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */ ASSERT (strlen (result) == 50 + 3 - && strisnan (result, strspn (result, " "), strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, strspn (result, " "), strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -428,9 +428,9 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%La %d", 3.1416015625L, 33, 44, 55); ASSERT (strcmp (result, "0x1.922p+1 33") == 0 - || strcmp (result, "0x3.244p+0 33") == 0 - || strcmp (result, "0x6.488p-1 33") == 0 - || strcmp (result, "0xc.91p-2 33") == 0); + || strcmp (result, "0x3.244p+0 33") == 0 + || strcmp (result, "0x6.488p-1 33") == 0 + || strcmp (result, "0xc.91p-2 33") == 0); ASSERT (retval == strlen (result)); } @@ -439,9 +439,9 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%LA %d", -3.1416015625L, 33, 44, 55); ASSERT (strcmp (result, "-0X1.922P+1 33") == 0 - || strcmp (result, "-0X3.244P+0 33") == 0 - || strcmp (result, "-0X6.488P-1 33") == 0 - || strcmp (result, "-0XC.91P-2 33") == 0); + || strcmp (result, "-0X3.244P+0 33") == 0 + || strcmp (result, "-0X6.488P-1 33") == 0 + || strcmp (result, "-0XC.91P-2 33") == 0); ASSERT (retval == strlen (result)); } @@ -483,8 +483,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%La %d", NaNl (), 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && strisnan (result, 0, strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } #if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) @@ -495,8 +495,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%La %d", x.value, 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && strisnan (result, 0, strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } { @@ -507,8 +507,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%La %d", x.value, 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && strisnan (result, 0, strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } /* The isnanl function should recognize Pseudo-NaNs, Pseudo-Infinities, @@ -525,8 +525,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%La %d", x.value, 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && strisnan (result, 0, strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } { /* Pseudo-Infinity. */ @@ -536,8 +536,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%La %d", x.value, 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && strisnan (result, 0, strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } { /* Pseudo-Zero. */ @@ -547,8 +547,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%La %d", x.value, 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && strisnan (result, 0, strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } { /* Unnormalized number. */ @@ -558,8 +558,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%La %d", x.value, 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && strisnan (result, 0, strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } { /* Pseudo-Denormal. */ @@ -569,8 +569,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%La %d", x.value, 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && strisnan (result, 0, strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } #endif @@ -580,9 +580,9 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%.0La %d", 1.5L, 33, 44, 55); ASSERT (strcmp (result, "0x2p+0 33") == 0 - || strcmp (result, "0x3p-1 33") == 0 - || strcmp (result, "0x6p-2 33") == 0 - || strcmp (result, "0xcp-3 33") == 0); + || strcmp (result, "0x3p-1 33") == 0 + || strcmp (result, "0x6p-2 33") == 0 + || strcmp (result, "0xcp-3 33") == 0); ASSERT (retval == strlen (result)); } @@ -591,9 +591,9 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%.0La %d", 1.51L, 33, 44, 55); ASSERT (strcmp (result, "0x2p+0 33") == 0 - || strcmp (result, "0x3p-1 33") == 0 - || strcmp (result, "0x6p-2 33") == 0 - || strcmp (result, "0xcp-3 33") == 0); + || strcmp (result, "0x3p-1 33") == 0 + || strcmp (result, "0x6p-2 33") == 0 + || strcmp (result, "0xcp-3 33") == 0); ASSERT (retval == strlen (result)); } @@ -602,9 +602,9 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%.1La %d", 1.51L, 33, 44, 55); ASSERT (strcmp (result, "0x1.8p+0 33") == 0 - || strcmp (result, "0x3.0p-1 33") == 0 - || strcmp (result, "0x6.1p-2 33") == 0 - || strcmp (result, "0xc.1p-3 33") == 0); + || strcmp (result, "0x3.0p-1 33") == 0 + || strcmp (result, "0x6.1p-2 33") == 0 + || strcmp (result, "0xc.1p-3 33") == 0); ASSERT (retval == strlen (result)); } @@ -613,9 +613,9 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%.2La %d", 1.51L, 33, 44, 55); ASSERT (strcmp (result, "0x1.83p+0 33") == 0 - || strcmp (result, "0x3.05p-1 33") == 0 - || strcmp (result, "0x6.0ap-2 33") == 0 - || strcmp (result, "0xc.14p-3 33") == 0); + || strcmp (result, "0x3.05p-1 33") == 0 + || strcmp (result, "0x6.0ap-2 33") == 0 + || strcmp (result, "0xc.14p-3 33") == 0); ASSERT (retval == strlen (result)); } @@ -624,9 +624,9 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%.3La %d", 1.51L, 33, 44, 55); ASSERT (strcmp (result, "0x1.829p+0 33") == 0 - || strcmp (result, "0x3.052p-1 33") == 0 - || strcmp (result, "0x6.0a4p-2 33") == 0 - || strcmp (result, "0xc.148p-3 33") == 0); + || strcmp (result, "0x3.052p-1 33") == 0 + || strcmp (result, "0x6.0a4p-2 33") == 0 + || strcmp (result, "0xc.148p-3 33") == 0); ASSERT (retval == strlen (result)); } @@ -635,9 +635,9 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%.3La %d", 1.49999L, 33, 44, 55); ASSERT (strcmp (result, "0x1.800p+0 33") == 0 - || strcmp (result, "0x3.000p-1 33") == 0 - || strcmp (result, "0x6.000p-2 33") == 0 - || strcmp (result, "0xc.000p-3 33") == 0); + || strcmp (result, "0x3.000p-1 33") == 0 + || strcmp (result, "0x6.000p-2 33") == 0 + || strcmp (result, "0xc.000p-3 33") == 0); ASSERT (retval == strlen (result)); } @@ -648,9 +648,9 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%.1La %d", 1.999L, 33, 44, 55); ASSERT (strcmp (result, "0x1.0p+1 33") == 0 - || strcmp (result, "0x2.0p+0 33") == 0 - || strcmp (result, "0x4.0p-1 33") == 0 - || strcmp (result, "0x8.0p-2 33") == 0); + || strcmp (result, "0x2.0p+0 33") == 0 + || strcmp (result, "0x4.0p-1 33") == 0 + || strcmp (result, "0x8.0p-2 33") == 0); ASSERT (retval == strlen (result)); } @@ -659,9 +659,9 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%10La %d", 1.75L, 33, 44, 55); ASSERT (strcmp (result, " 0x1.cp+0 33") == 0 - || strcmp (result, " 0x3.8p-1 33") == 0 - || strcmp (result, " 0x7p-2 33") == 0 - || strcmp (result, " 0xep-3 33") == 0); + || strcmp (result, " 0x3.8p-1 33") == 0 + || strcmp (result, " 0x7p-2 33") == 0 + || strcmp (result, " 0xep-3 33") == 0); ASSERT (retval == strlen (result)); } @@ -670,9 +670,9 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%.10La %d", 1.75L, 33, 44, 55); ASSERT (strcmp (result, "0x1.c000000000p+0 33") == 0 - || strcmp (result, "0x3.8000000000p-1 33") == 0 - || strcmp (result, "0x7.0000000000p-2 33") == 0 - || strcmp (result, "0xe.0000000000p-3 33") == 0); + || strcmp (result, "0x3.8000000000p-1 33") == 0 + || strcmp (result, "0x7.0000000000p-2 33") == 0 + || strcmp (result, "0xe.0000000000p-3 33") == 0); ASSERT (retval == strlen (result)); } @@ -681,9 +681,9 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%.50La %d", 1.75L, 33, 44, 55); ASSERT (strcmp (result, "0x1.c0000000000000000000000000000000000000000000000000p+0 33") == 0 - || strcmp (result, "0x3.80000000000000000000000000000000000000000000000000p-1 33") == 0 - || strcmp (result, "0x7.00000000000000000000000000000000000000000000000000p-2 33") == 0 - || strcmp (result, "0xe.00000000000000000000000000000000000000000000000000p-3 33") == 0); + || strcmp (result, "0x3.80000000000000000000000000000000000000000000000000p-1 33") == 0 + || strcmp (result, "0x7.00000000000000000000000000000000000000000000000000p-2 33") == 0 + || strcmp (result, "0xe.00000000000000000000000000000000000000000000000000p-3 33") == 0); ASSERT (retval == strlen (result)); } @@ -692,9 +692,9 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%-10La %d", 1.75L, 33, 44, 55); ASSERT (strcmp (result, "0x1.cp+0 33") == 0 - || strcmp (result, "0x3.8p-1 33") == 0 - || strcmp (result, "0x7p-2 33") == 0 - || strcmp (result, "0xep-3 33") == 0); + || strcmp (result, "0x3.8p-1 33") == 0 + || strcmp (result, "0x7p-2 33") == 0 + || strcmp (result, "0xep-3 33") == 0); ASSERT (retval == strlen (result)); } @@ -703,9 +703,9 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%+La %d", 1.75L, 33, 44, 55); ASSERT (strcmp (result, "+0x1.cp+0 33") == 0 - || strcmp (result, "+0x3.8p-1 33") == 0 - || strcmp (result, "+0x7p-2 33") == 0 - || strcmp (result, "+0xep-3 33") == 0); + || strcmp (result, "+0x3.8p-1 33") == 0 + || strcmp (result, "+0x7p-2 33") == 0 + || strcmp (result, "+0xep-3 33") == 0); ASSERT (retval == strlen (result)); } @@ -714,9 +714,9 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "% La %d", 1.75L, 33, 44, 55); ASSERT (strcmp (result, " 0x1.cp+0 33") == 0 - || strcmp (result, " 0x3.8p-1 33") == 0 - || strcmp (result, " 0x7p-2 33") == 0 - || strcmp (result, " 0xep-3 33") == 0); + || strcmp (result, " 0x3.8p-1 33") == 0 + || strcmp (result, " 0x7p-2 33") == 0 + || strcmp (result, " 0xep-3 33") == 0); ASSERT (retval == strlen (result)); } @@ -725,9 +725,9 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%#La %d", 1.75L, 33, 44, 55); ASSERT (strcmp (result, "0x1.cp+0 33") == 0 - || strcmp (result, "0x3.8p-1 33") == 0 - || strcmp (result, "0x7.p-2 33") == 0 - || strcmp (result, "0xe.p-3 33") == 0); + || strcmp (result, "0x3.8p-1 33") == 0 + || strcmp (result, "0x7.p-2 33") == 0 + || strcmp (result, "0xe.p-3 33") == 0); ASSERT (retval == strlen (result)); } @@ -736,9 +736,9 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%#La %d", 1.0L, 33, 44, 55); ASSERT (strcmp (result, "0x1.p+0 33") == 0 - || strcmp (result, "0x2.p-1 33") == 0 - || strcmp (result, "0x4.p-2 33") == 0 - || strcmp (result, "0x8.p-3 33") == 0); + || strcmp (result, "0x2.p-1 33") == 0 + || strcmp (result, "0x4.p-2 33") == 0 + || strcmp (result, "0x8.p-3 33") == 0); ASSERT (retval == strlen (result)); } @@ -747,9 +747,9 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%010La %d", 1.75L, 33, 44, 55); ASSERT (strcmp (result, "0x001.cp+0 33") == 0 - || strcmp (result, "0x003.8p-1 33") == 0 - || strcmp (result, "0x00007p-2 33") == 0 - || strcmp (result, "0x0000ep-3 33") == 0); + || strcmp (result, "0x003.8p-1 33") == 0 + || strcmp (result, "0x00007p-2 33") == 0 + || strcmp (result, "0x0000ep-3 33") == 0); ASSERT (retval == strlen (result)); } @@ -770,8 +770,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) /* "0000000nan 33" is not a valid result; see <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */ ASSERT (strlen (result) == 50 + 3 - && strisnan (result, strspn (result, " "), strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, strspn (result, " "), strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -796,89 +796,89 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) { /* Small and large positive numbers. */ static struct { double value; const char *string; } data[] = { - { 1.234321234321234e-37, "0.000000" }, - { 1.234321234321234e-36, "0.000000" }, - { 1.234321234321234e-35, "0.000000" }, - { 1.234321234321234e-34, "0.000000" }, - { 1.234321234321234e-33, "0.000000" }, - { 1.234321234321234e-32, "0.000000" }, - { 1.234321234321234e-31, "0.000000" }, - { 1.234321234321234e-30, "0.000000" }, - { 1.234321234321234e-29, "0.000000" }, - { 1.234321234321234e-28, "0.000000" }, - { 1.234321234321234e-27, "0.000000" }, - { 1.234321234321234e-26, "0.000000" }, - { 1.234321234321234e-25, "0.000000" }, - { 1.234321234321234e-24, "0.000000" }, - { 1.234321234321234e-23, "0.000000" }, - { 1.234321234321234e-22, "0.000000" }, - { 1.234321234321234e-21, "0.000000" }, - { 1.234321234321234e-20, "0.000000" }, - { 1.234321234321234e-19, "0.000000" }, - { 1.234321234321234e-18, "0.000000" }, - { 1.234321234321234e-17, "0.000000" }, - { 1.234321234321234e-16, "0.000000" }, - { 1.234321234321234e-15, "0.000000" }, - { 1.234321234321234e-14, "0.000000" }, - { 1.234321234321234e-13, "0.000000" }, - { 1.234321234321234e-12, "0.000000" }, - { 1.234321234321234e-11, "0.000000" }, - { 1.234321234321234e-10, "0.000000" }, - { 1.234321234321234e-9, "0.000000" }, - { 1.234321234321234e-8, "0.000000" }, - { 1.234321234321234e-7, "0.000000" }, - { 1.234321234321234e-6, "0.000001" }, - { 1.234321234321234e-5, "0.000012" }, - { 1.234321234321234e-4, "0.000123" }, - { 1.234321234321234e-3, "0.001234" }, - { 1.234321234321234e-2, "0.012343" }, - { 1.234321234321234e-1, "0.123432" }, - { 1.234321234321234, "1.234321" }, - { 1.234321234321234e1, "12.343212" }, - { 1.234321234321234e2, "123.432123" }, - { 1.234321234321234e3, "1234.321234" }, - { 1.234321234321234e4, "12343.212343" }, - { 1.234321234321234e5, "123432.123432" }, - { 1.234321234321234e6, "1234321.234321" }, - { 1.234321234321234e7, "12343212.343212" }, - { 1.234321234321234e8, "123432123.432123" }, - { 1.234321234321234e9, "1234321234.321234" }, - { 1.234321234321234e10, "12343212343.2123**" }, - { 1.234321234321234e11, "123432123432.123***" }, - { 1.234321234321234e12, "1234321234321.23****" }, - { 1.234321234321234e13, "12343212343212.3*****" }, - { 1.234321234321234e14, "123432123432123.******" }, - { 1.234321234321234e15, "1234321234321234.000000" }, - { 1.234321234321234e16, "123432123432123**.000000" }, - { 1.234321234321234e17, "123432123432123***.000000" }, - { 1.234321234321234e18, "123432123432123****.000000" }, - { 1.234321234321234e19, "123432123432123*****.000000" }, - { 1.234321234321234e20, "123432123432123******.000000" }, - { 1.234321234321234e21, "123432123432123*******.000000" }, - { 1.234321234321234e22, "123432123432123********.000000" }, - { 1.234321234321234e23, "123432123432123*********.000000" }, - { 1.234321234321234e24, "123432123432123**********.000000" }, - { 1.234321234321234e25, "123432123432123***********.000000" }, - { 1.234321234321234e26, "123432123432123************.000000" }, - { 1.234321234321234e27, "123432123432123*************.000000" }, - { 1.234321234321234e28, "123432123432123**************.000000" }, - { 1.234321234321234e29, "123432123432123***************.000000" }, - { 1.234321234321234e30, "123432123432123****************.000000" }, - { 1.234321234321234e31, "123432123432123*****************.000000" }, - { 1.234321234321234e32, "123432123432123******************.000000" }, - { 1.234321234321234e33, "123432123432123*******************.000000" }, - { 1.234321234321234e34, "123432123432123********************.000000" }, - { 1.234321234321234e35, "123432123432123*********************.000000" }, - { 1.234321234321234e36, "123432123432123**********************.000000" } + { 1.234321234321234e-37, "0.000000" }, + { 1.234321234321234e-36, "0.000000" }, + { 1.234321234321234e-35, "0.000000" }, + { 1.234321234321234e-34, "0.000000" }, + { 1.234321234321234e-33, "0.000000" }, + { 1.234321234321234e-32, "0.000000" }, + { 1.234321234321234e-31, "0.000000" }, + { 1.234321234321234e-30, "0.000000" }, + { 1.234321234321234e-29, "0.000000" }, + { 1.234321234321234e-28, "0.000000" }, + { 1.234321234321234e-27, "0.000000" }, + { 1.234321234321234e-26, "0.000000" }, + { 1.234321234321234e-25, "0.000000" }, + { 1.234321234321234e-24, "0.000000" }, + { 1.234321234321234e-23, "0.000000" }, + { 1.234321234321234e-22, "0.000000" }, + { 1.234321234321234e-21, "0.000000" }, + { 1.234321234321234e-20, "0.000000" }, + { 1.234321234321234e-19, "0.000000" }, + { 1.234321234321234e-18, "0.000000" }, + { 1.234321234321234e-17, "0.000000" }, + { 1.234321234321234e-16, "0.000000" }, + { 1.234321234321234e-15, "0.000000" }, + { 1.234321234321234e-14, "0.000000" }, + { 1.234321234321234e-13, "0.000000" }, + { 1.234321234321234e-12, "0.000000" }, + { 1.234321234321234e-11, "0.000000" }, + { 1.234321234321234e-10, "0.000000" }, + { 1.234321234321234e-9, "0.000000" }, + { 1.234321234321234e-8, "0.000000" }, + { 1.234321234321234e-7, "0.000000" }, + { 1.234321234321234e-6, "0.000001" }, + { 1.234321234321234e-5, "0.000012" }, + { 1.234321234321234e-4, "0.000123" }, + { 1.234321234321234e-3, "0.001234" }, + { 1.234321234321234e-2, "0.012343" }, + { 1.234321234321234e-1, "0.123432" }, + { 1.234321234321234, "1.234321" }, + { 1.234321234321234e1, "12.343212" }, + { 1.234321234321234e2, "123.432123" }, + { 1.234321234321234e3, "1234.321234" }, + { 1.234321234321234e4, "12343.212343" }, + { 1.234321234321234e5, "123432.123432" }, + { 1.234321234321234e6, "1234321.234321" }, + { 1.234321234321234e7, "12343212.343212" }, + { 1.234321234321234e8, "123432123.432123" }, + { 1.234321234321234e9, "1234321234.321234" }, + { 1.234321234321234e10, "12343212343.2123**" }, + { 1.234321234321234e11, "123432123432.123***" }, + { 1.234321234321234e12, "1234321234321.23****" }, + { 1.234321234321234e13, "12343212343212.3*****" }, + { 1.234321234321234e14, "123432123432123.******" }, + { 1.234321234321234e15, "1234321234321234.000000" }, + { 1.234321234321234e16, "123432123432123**.000000" }, + { 1.234321234321234e17, "123432123432123***.000000" }, + { 1.234321234321234e18, "123432123432123****.000000" }, + { 1.234321234321234e19, "123432123432123*****.000000" }, + { 1.234321234321234e20, "123432123432123******.000000" }, + { 1.234321234321234e21, "123432123432123*******.000000" }, + { 1.234321234321234e22, "123432123432123********.000000" }, + { 1.234321234321234e23, "123432123432123*********.000000" }, + { 1.234321234321234e24, "123432123432123**********.000000" }, + { 1.234321234321234e25, "123432123432123***********.000000" }, + { 1.234321234321234e26, "123432123432123************.000000" }, + { 1.234321234321234e27, "123432123432123*************.000000" }, + { 1.234321234321234e28, "123432123432123**************.000000" }, + { 1.234321234321234e29, "123432123432123***************.000000" }, + { 1.234321234321234e30, "123432123432123****************.000000" }, + { 1.234321234321234e31, "123432123432123*****************.000000" }, + { 1.234321234321234e32, "123432123432123******************.000000" }, + { 1.234321234321234e33, "123432123432123*******************.000000" }, + { 1.234321234321234e34, "123432123432123********************.000000" }, + { 1.234321234321234e35, "123432123432123*********************.000000" }, + { 1.234321234321234e36, "123432123432123**********************.000000" } }; size_t k; for (k = 0; k < SIZEOF (data); k++) { - char result[100]; - int retval = - my_snprintf (result, sizeof (result), "%f", data[k].value); - ASSERT (strmatch (data[k].string, result)); - ASSERT (retval == strlen (result)); + char result[100]; + int retval = + my_snprintf (result, sizeof (result), "%f", data[k].value); + ASSERT (strmatch (data[k].string, result)); + ASSERT (retval == strlen (result)); } } @@ -912,7 +912,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%f %d", 1.0 / 0.0, 33, 44, 55); ASSERT (strcmp (result, "inf 33") == 0 - || strcmp (result, "infinity 33") == 0); + || strcmp (result, "infinity 33") == 0); ASSERT (retval == strlen (result)); } @@ -921,7 +921,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%f %d", -1.0 / 0.0, 33, 44, 55); ASSERT (strcmp (result, "-inf 33") == 0 - || strcmp (result, "-infinity 33") == 0); + || strcmp (result, "-infinity 33") == 0); ASSERT (retval == strlen (result)); } @@ -930,8 +930,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%f %d", NaNd (), 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && strisnan (result, 0, strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -996,7 +996,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%015f %d", -1.0 / 0.0, 33, 44, 55); ASSERT (strcmp (result, " -inf 33") == 0 - || strcmp (result, " -infinity 33") == 0); + || strcmp (result, " -infinity 33") == 0); ASSERT (retval == strlen (result)); } @@ -1005,8 +1005,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%050f %d", NaNd (), 33, 44, 55); ASSERT (strlen (result) == 50 + 3 - && strisnan (result, strspn (result, " "), strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, strspn (result, " "), strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -1053,89 +1053,89 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) { /* Small and large positive numbers. */ static struct { long double value; const char *string; } data[] = { - { 1.234321234321234e-37L, "0.000000" }, - { 1.234321234321234e-36L, "0.000000" }, - { 1.234321234321234e-35L, "0.000000" }, - { 1.234321234321234e-34L, "0.000000" }, - { 1.234321234321234e-33L, "0.000000" }, - { 1.234321234321234e-32L, "0.000000" }, - { 1.234321234321234e-31L, "0.000000" }, - { 1.234321234321234e-30L, "0.000000" }, - { 1.234321234321234e-29L, "0.000000" }, - { 1.234321234321234e-28L, "0.000000" }, - { 1.234321234321234e-27L, "0.000000" }, - { 1.234321234321234e-26L, "0.000000" }, - { 1.234321234321234e-25L, "0.000000" }, - { 1.234321234321234e-24L, "0.000000" }, - { 1.234321234321234e-23L, "0.000000" }, - { 1.234321234321234e-22L, "0.000000" }, - { 1.234321234321234e-21L, "0.000000" }, - { 1.234321234321234e-20L, "0.000000" }, - { 1.234321234321234e-19L, "0.000000" }, - { 1.234321234321234e-18L, "0.000000" }, - { 1.234321234321234e-17L, "0.000000" }, - { 1.234321234321234e-16L, "0.000000" }, - { 1.234321234321234e-15L, "0.000000" }, - { 1.234321234321234e-14L, "0.000000" }, - { 1.234321234321234e-13L, "0.000000" }, - { 1.234321234321234e-12L, "0.000000" }, - { 1.234321234321234e-11L, "0.000000" }, - { 1.234321234321234e-10L, "0.000000" }, - { 1.234321234321234e-9L, "0.000000" }, - { 1.234321234321234e-8L, "0.000000" }, - { 1.234321234321234e-7L, "0.000000" }, - { 1.234321234321234e-6L, "0.000001" }, - { 1.234321234321234e-5L, "0.000012" }, - { 1.234321234321234e-4L, "0.000123" }, - { 1.234321234321234e-3L, "0.001234" }, - { 1.234321234321234e-2L, "0.012343" }, - { 1.234321234321234e-1L, "0.123432" }, - { 1.234321234321234L, "1.234321" }, - { 1.234321234321234e1L, "12.343212" }, - { 1.234321234321234e2L, "123.432123" }, - { 1.234321234321234e3L, "1234.321234" }, - { 1.234321234321234e4L, "12343.212343" }, - { 1.234321234321234e5L, "123432.123432" }, - { 1.234321234321234e6L, "1234321.234321" }, - { 1.234321234321234e7L, "12343212.343212" }, - { 1.234321234321234e8L, "123432123.432123" }, - { 1.234321234321234e9L, "1234321234.321234" }, - { 1.234321234321234e10L, "12343212343.2123**" }, - { 1.234321234321234e11L, "123432123432.123***" }, - { 1.234321234321234e12L, "1234321234321.23****" }, - { 1.234321234321234e13L, "12343212343212.3*****" }, - { 1.234321234321234e14L, "123432123432123.******" }, - { 1.234321234321234e15L, "1234321234321234.000000" }, - { 1.234321234321234e16L, "123432123432123**.000000" }, - { 1.234321234321234e17L, "123432123432123***.000000" }, - { 1.234321234321234e18L, "123432123432123****.000000" }, - { 1.234321234321234e19L, "123432123432123*****.000000" }, - { 1.234321234321234e20L, "123432123432123******.000000" }, - { 1.234321234321234e21L, "123432123432123*******.000000" }, - { 1.234321234321234e22L, "123432123432123********.000000" }, - { 1.234321234321234e23L, "123432123432123*********.000000" }, - { 1.234321234321234e24L, "123432123432123**********.000000" }, - { 1.234321234321234e25L, "123432123432123***********.000000" }, - { 1.234321234321234e26L, "123432123432123************.000000" }, - { 1.234321234321234e27L, "123432123432123*************.000000" }, - { 1.234321234321234e28L, "123432123432123**************.000000" }, - { 1.234321234321234e29L, "123432123432123***************.000000" }, - { 1.234321234321234e30L, "123432123432123****************.000000" }, - { 1.234321234321234e31L, "123432123432123*****************.000000" }, - { 1.234321234321234e32L, "123432123432123******************.000000" }, - { 1.234321234321234e33L, "123432123432123*******************.000000" }, - { 1.234321234321234e34L, "123432123432123********************.000000" }, - { 1.234321234321234e35L, "123432123432123*********************.000000" }, - { 1.234321234321234e36L, "123432123432123**********************.000000" } + { 1.234321234321234e-37L, "0.000000" }, + { 1.234321234321234e-36L, "0.000000" }, + { 1.234321234321234e-35L, "0.000000" }, + { 1.234321234321234e-34L, "0.000000" }, + { 1.234321234321234e-33L, "0.000000" }, + { 1.234321234321234e-32L, "0.000000" }, + { 1.234321234321234e-31L, "0.000000" }, + { 1.234321234321234e-30L, "0.000000" }, + { 1.234321234321234e-29L, "0.000000" }, + { 1.234321234321234e-28L, "0.000000" }, + { 1.234321234321234e-27L, "0.000000" }, + { 1.234321234321234e-26L, "0.000000" }, + { 1.234321234321234e-25L, "0.000000" }, + { 1.234321234321234e-24L, "0.000000" }, + { 1.234321234321234e-23L, "0.000000" }, + { 1.234321234321234e-22L, "0.000000" }, + { 1.234321234321234e-21L, "0.000000" }, + { 1.234321234321234e-20L, "0.000000" }, + { 1.234321234321234e-19L, "0.000000" }, + { 1.234321234321234e-18L, "0.000000" }, + { 1.234321234321234e-17L, "0.000000" }, + { 1.234321234321234e-16L, "0.000000" }, + { 1.234321234321234e-15L, "0.000000" }, + { 1.234321234321234e-14L, "0.000000" }, + { 1.234321234321234e-13L, "0.000000" }, + { 1.234321234321234e-12L, "0.000000" }, + { 1.234321234321234e-11L, "0.000000" }, + { 1.234321234321234e-10L, "0.000000" }, + { 1.234321234321234e-9L, "0.000000" }, + { 1.234321234321234e-8L, "0.000000" }, + { 1.234321234321234e-7L, "0.000000" }, + { 1.234321234321234e-6L, "0.000001" }, + { 1.234321234321234e-5L, "0.000012" }, + { 1.234321234321234e-4L, "0.000123" }, + { 1.234321234321234e-3L, "0.001234" }, + { 1.234321234321234e-2L, "0.012343" }, + { 1.234321234321234e-1L, "0.123432" }, + { 1.234321234321234L, "1.234321" }, + { 1.234321234321234e1L, "12.343212" }, + { 1.234321234321234e2L, "123.432123" }, + { 1.234321234321234e3L, "1234.321234" }, + { 1.234321234321234e4L, "12343.212343" }, + { 1.234321234321234e5L, "123432.123432" }, + { 1.234321234321234e6L, "1234321.234321" }, + { 1.234321234321234e7L, "12343212.343212" }, + { 1.234321234321234e8L, "123432123.432123" }, + { 1.234321234321234e9L, "1234321234.321234" }, + { 1.234321234321234e10L, "12343212343.2123**" }, + { 1.234321234321234e11L, "123432123432.123***" }, + { 1.234321234321234e12L, "1234321234321.23****" }, + { 1.234321234321234e13L, "12343212343212.3*****" }, + { 1.234321234321234e14L, "123432123432123.******" }, + { 1.234321234321234e15L, "1234321234321234.000000" }, + { 1.234321234321234e16L, "123432123432123**.000000" }, + { 1.234321234321234e17L, "123432123432123***.000000" }, + { 1.234321234321234e18L, "123432123432123****.000000" }, + { 1.234321234321234e19L, "123432123432123*****.000000" }, + { 1.234321234321234e20L, "123432123432123******.000000" }, + { 1.234321234321234e21L, "123432123432123*******.000000" }, + { 1.234321234321234e22L, "123432123432123********.000000" }, + { 1.234321234321234e23L, "123432123432123*********.000000" }, + { 1.234321234321234e24L, "123432123432123**********.000000" }, + { 1.234321234321234e25L, "123432123432123***********.000000" }, + { 1.234321234321234e26L, "123432123432123************.000000" }, + { 1.234321234321234e27L, "123432123432123*************.000000" }, + { 1.234321234321234e28L, "123432123432123**************.000000" }, + { 1.234321234321234e29L, "123432123432123***************.000000" }, + { 1.234321234321234e30L, "123432123432123****************.000000" }, + { 1.234321234321234e31L, "123432123432123*****************.000000" }, + { 1.234321234321234e32L, "123432123432123******************.000000" }, + { 1.234321234321234e33L, "123432123432123*******************.000000" }, + { 1.234321234321234e34L, "123432123432123********************.000000" }, + { 1.234321234321234e35L, "123432123432123*********************.000000" }, + { 1.234321234321234e36L, "123432123432123**********************.000000" } }; size_t k; for (k = 0; k < SIZEOF (data); k++) { - char result[100]; - int retval = - my_snprintf (result, sizeof (result), "%Lf", data[k].value); - ASSERT (strmatch (data[k].string, result)); - ASSERT (retval == strlen (result)); + char result[100]; + int retval = + my_snprintf (result, sizeof (result), "%Lf", data[k].value); + ASSERT (strmatch (data[k].string, result)); + ASSERT (retval == strlen (result)); } } @@ -1169,7 +1169,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%Lf %d", 1.0L / 0.0L, 33, 44, 55); ASSERT (strcmp (result, "inf 33") == 0 - || strcmp (result, "infinity 33") == 0); + || strcmp (result, "infinity 33") == 0); ASSERT (retval == strlen (result)); } @@ -1178,7 +1178,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%Lf %d", -1.0L / 0.0L, 33, 44, 55); ASSERT (strcmp (result, "-inf 33") == 0 - || strcmp (result, "-infinity 33") == 0); + || strcmp (result, "-infinity 33") == 0); ASSERT (retval == strlen (result)); } @@ -1187,8 +1187,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%Lf %d", NaNl (), 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && strisnan (result, 0, strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } #if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) @@ -1199,8 +1199,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%Lf %d", x.value, 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && strisnan (result, 0, strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } { @@ -1211,8 +1211,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%Lf %d", x.value, 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && strisnan (result, 0, strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } /* The isnanl function should recognize Pseudo-NaNs, Pseudo-Infinities, @@ -1229,8 +1229,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%Lf %d", x.value, 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && strisnan (result, 0, strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } { /* Pseudo-Infinity. */ @@ -1240,8 +1240,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%Lf %d", x.value, 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && strisnan (result, 0, strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } { /* Pseudo-Zero. */ @@ -1251,8 +1251,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%Lf %d", x.value, 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && strisnan (result, 0, strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } { /* Unnormalized number. */ @@ -1262,8 +1262,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%Lf %d", x.value, 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && strisnan (result, 0, strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } { /* Pseudo-Denormal. */ @@ -1273,8 +1273,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%Lf %d", x.value, 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && strisnan (result, 0, strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } #endif @@ -1340,7 +1340,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%015Lf %d", -1.0L / 0.0L, 33, 44, 55); ASSERT (strcmp (result, " -inf 33") == 0 - || strcmp (result, " -infinity 33") == 0); + || strcmp (result, " -infinity 33") == 0); ASSERT (retval == strlen (result)); } @@ -1349,8 +1349,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%050Lf %d", NaNl (), 33, 44, 55); ASSERT (strlen (result) == 50 + 3 - && strisnan (result, strspn (result, " "), strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, strspn (result, " "), strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -1426,7 +1426,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%F %d", 1.0 / 0.0, 33, 44, 55); ASSERT (strcmp (result, "INF 33") == 0 - || strcmp (result, "INFINITY 33") == 0); + || strcmp (result, "INFINITY 33") == 0); ASSERT (retval == strlen (result)); } @@ -1435,7 +1435,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%F %d", -1.0 / 0.0, 33, 44, 55); ASSERT (strcmp (result, "-INF 33") == 0 - || strcmp (result, "-INFINITY 33") == 0); + || strcmp (result, "-INFINITY 33") == 0); ASSERT (retval == strlen (result)); } @@ -1444,8 +1444,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%F %d", NaNd (), 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && strisnan (result, 0, strlen (result) - 3, 1) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, 0, strlen (result) - 3, 1) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -1462,7 +1462,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%015F %d", -1.0 / 0.0, 33, 44, 55); ASSERT (strcmp (result, " -INF 33") == 0 - || strcmp (result, " -INFINITY 33") == 0); + || strcmp (result, " -INFINITY 33") == 0); ASSERT (retval == strlen (result)); } @@ -1536,7 +1536,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%LF %d", 1.0L / 0.0L, 33, 44, 55); ASSERT (strcmp (result, "INF 33") == 0 - || strcmp (result, "INFINITY 33") == 0); + || strcmp (result, "INFINITY 33") == 0); ASSERT (retval == strlen (result)); } @@ -1545,7 +1545,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%LF %d", -1.0L / 0.0L, 33, 44, 55); ASSERT (strcmp (result, "-INF 33") == 0 - || strcmp (result, "-INFINITY 33") == 0); + || strcmp (result, "-INFINITY 33") == 0); ASSERT (retval == strlen (result)); } @@ -1554,8 +1554,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%LF %d", NaNl (), 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && strisnan (result, 0, strlen (result) - 3, 1) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, 0, strlen (result) - 3, 1) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -1572,7 +1572,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%015LF %d", -1.0L / 0.0L, 33, 44, 55); ASSERT (strcmp (result, " -INF 33") == 0 - || strcmp (result, " -INFINITY 33") == 0); + || strcmp (result, " -INFINITY 33") == 0); ASSERT (retval == strlen (result)); } @@ -1607,7 +1607,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%e %d", 12.75, 33, 44, 55); ASSERT (strcmp (result, "1.275000e+01 33") == 0 - || strcmp (result, "1.275000e+001 33") == 0); + || strcmp (result, "1.275000e+001 33") == 0); ASSERT (retval == strlen (result)); } @@ -1616,104 +1616,104 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%e %d", 1234567.0, 33, 44, 55); ASSERT (strcmp (result, "1.234567e+06 33") == 0 - || strcmp (result, "1.234567e+006 33") == 0); + || strcmp (result, "1.234567e+006 33") == 0); ASSERT (retval == strlen (result)); } { /* Small and large positive numbers. */ static struct { double value; const char *string; } data[] = { - { 1.234321234321234e-37, "1.234321e-37" }, - { 1.234321234321234e-36, "1.234321e-36" }, - { 1.234321234321234e-35, "1.234321e-35" }, - { 1.234321234321234e-34, "1.234321e-34" }, - { 1.234321234321234e-33, "1.234321e-33" }, - { 1.234321234321234e-32, "1.234321e-32" }, - { 1.234321234321234e-31, "1.234321e-31" }, - { 1.234321234321234e-30, "1.234321e-30" }, - { 1.234321234321234e-29, "1.234321e-29" }, - { 1.234321234321234e-28, "1.234321e-28" }, - { 1.234321234321234e-27, "1.234321e-27" }, - { 1.234321234321234e-26, "1.234321e-26" }, - { 1.234321234321234e-25, "1.234321e-25" }, - { 1.234321234321234e-24, "1.234321e-24" }, - { 1.234321234321234e-23, "1.234321e-23" }, - { 1.234321234321234e-22, "1.234321e-22" }, - { 1.234321234321234e-21, "1.234321e-21" }, - { 1.234321234321234e-20, "1.234321e-20" }, - { 1.234321234321234e-19, "1.234321e-19" }, - { 1.234321234321234e-18, "1.234321e-18" }, - { 1.234321234321234e-17, "1.234321e-17" }, - { 1.234321234321234e-16, "1.234321e-16" }, - { 1.234321234321234e-15, "1.234321e-15" }, - { 1.234321234321234e-14, "1.234321e-14" }, - { 1.234321234321234e-13, "1.234321e-13" }, - { 1.234321234321234e-12, "1.234321e-12" }, - { 1.234321234321234e-11, "1.234321e-11" }, - { 1.234321234321234e-10, "1.234321e-10" }, - { 1.234321234321234e-9, "1.234321e-09" }, - { 1.234321234321234e-8, "1.234321e-08" }, - { 1.234321234321234e-7, "1.234321e-07" }, - { 1.234321234321234e-6, "1.234321e-06" }, - { 1.234321234321234e-5, "1.234321e-05" }, - { 1.234321234321234e-4, "1.234321e-04" }, - { 1.234321234321234e-3, "1.234321e-03" }, - { 1.234321234321234e-2, "1.234321e-02" }, - { 1.234321234321234e-1, "1.234321e-01" }, - { 1.234321234321234, "1.234321e+00" }, - { 1.234321234321234e1, "1.234321e+01" }, - { 1.234321234321234e2, "1.234321e+02" }, - { 1.234321234321234e3, "1.234321e+03" }, - { 1.234321234321234e4, "1.234321e+04" }, - { 1.234321234321234e5, "1.234321e+05" }, - { 1.234321234321234e6, "1.234321e+06" }, - { 1.234321234321234e7, "1.234321e+07" }, - { 1.234321234321234e8, "1.234321e+08" }, - { 1.234321234321234e9, "1.234321e+09" }, - { 1.234321234321234e10, "1.234321e+10" }, - { 1.234321234321234e11, "1.234321e+11" }, - { 1.234321234321234e12, "1.234321e+12" }, - { 1.234321234321234e13, "1.234321e+13" }, - { 1.234321234321234e14, "1.234321e+14" }, - { 1.234321234321234e15, "1.234321e+15" }, - { 1.234321234321234e16, "1.234321e+16" }, - { 1.234321234321234e17, "1.234321e+17" }, - { 1.234321234321234e18, "1.234321e+18" }, - { 1.234321234321234e19, "1.234321e+19" }, - { 1.234321234321234e20, "1.234321e+20" }, - { 1.234321234321234e21, "1.234321e+21" }, - { 1.234321234321234e22, "1.234321e+22" }, - { 1.234321234321234e23, "1.234321e+23" }, - { 1.234321234321234e24, "1.234321e+24" }, - { 1.234321234321234e25, "1.234321e+25" }, - { 1.234321234321234e26, "1.234321e+26" }, - { 1.234321234321234e27, "1.234321e+27" }, - { 1.234321234321234e28, "1.234321e+28" }, - { 1.234321234321234e29, "1.234321e+29" }, - { 1.234321234321234e30, "1.234321e+30" }, - { 1.234321234321234e31, "1.234321e+31" }, - { 1.234321234321234e32, "1.234321e+32" }, - { 1.234321234321234e33, "1.234321e+33" }, - { 1.234321234321234e34, "1.234321e+34" }, - { 1.234321234321234e35, "1.234321e+35" }, - { 1.234321234321234e36, "1.234321e+36" } + { 1.234321234321234e-37, "1.234321e-37" }, + { 1.234321234321234e-36, "1.234321e-36" }, + { 1.234321234321234e-35, "1.234321e-35" }, + { 1.234321234321234e-34, "1.234321e-34" }, + { 1.234321234321234e-33, "1.234321e-33" }, + { 1.234321234321234e-32, "1.234321e-32" }, + { 1.234321234321234e-31, "1.234321e-31" }, + { 1.234321234321234e-30, "1.234321e-30" }, + { 1.234321234321234e-29, "1.234321e-29" }, + { 1.234321234321234e-28, "1.234321e-28" }, + { 1.234321234321234e-27, "1.234321e-27" }, + { 1.234321234321234e-26, "1.234321e-26" }, + { 1.234321234321234e-25, "1.234321e-25" }, + { 1.234321234321234e-24, "1.234321e-24" }, + { 1.234321234321234e-23, "1.234321e-23" }, + { 1.234321234321234e-22, "1.234321e-22" }, + { 1.234321234321234e-21, "1.234321e-21" }, + { 1.234321234321234e-20, "1.234321e-20" }, + { 1.234321234321234e-19, "1.234321e-19" }, + { 1.234321234321234e-18, "1.234321e-18" }, + { 1.234321234321234e-17, "1.234321e-17" }, + { 1.234321234321234e-16, "1.234321e-16" }, + { 1.234321234321234e-15, "1.234321e-15" }, + { 1.234321234321234e-14, "1.234321e-14" }, + { 1.234321234321234e-13, "1.234321e-13" }, + { 1.234321234321234e-12, "1.234321e-12" }, + { 1.234321234321234e-11, "1.234321e-11" }, + { 1.234321234321234e-10, "1.234321e-10" }, + { 1.234321234321234e-9, "1.234321e-09" }, + { 1.234321234321234e-8, "1.234321e-08" }, + { 1.234321234321234e-7, "1.234321e-07" }, + { 1.234321234321234e-6, "1.234321e-06" }, + { 1.234321234321234e-5, "1.234321e-05" }, + { 1.234321234321234e-4, "1.234321e-04" }, + { 1.234321234321234e-3, "1.234321e-03" }, + { 1.234321234321234e-2, "1.234321e-02" }, + { 1.234321234321234e-1, "1.234321e-01" }, + { 1.234321234321234, "1.234321e+00" }, + { 1.234321234321234e1, "1.234321e+01" }, + { 1.234321234321234e2, "1.234321e+02" }, + { 1.234321234321234e3, "1.234321e+03" }, + { 1.234321234321234e4, "1.234321e+04" }, + { 1.234321234321234e5, "1.234321e+05" }, + { 1.234321234321234e6, "1.234321e+06" }, + { 1.234321234321234e7, "1.234321e+07" }, + { 1.234321234321234e8, "1.234321e+08" }, + { 1.234321234321234e9, "1.234321e+09" }, + { 1.234321234321234e10, "1.234321e+10" }, + { 1.234321234321234e11, "1.234321e+11" }, + { 1.234321234321234e12, "1.234321e+12" }, + { 1.234321234321234e13, "1.234321e+13" }, + { 1.234321234321234e14, "1.234321e+14" }, + { 1.234321234321234e15, "1.234321e+15" }, + { 1.234321234321234e16, "1.234321e+16" }, + { 1.234321234321234e17, "1.234321e+17" }, + { 1.234321234321234e18, "1.234321e+18" }, + { 1.234321234321234e19, "1.234321e+19" }, + { 1.234321234321234e20, "1.234321e+20" }, + { 1.234321234321234e21, "1.234321e+21" }, + { 1.234321234321234e22, "1.234321e+22" }, + { 1.234321234321234e23, "1.234321e+23" }, + { 1.234321234321234e24, "1.234321e+24" }, + { 1.234321234321234e25, "1.234321e+25" }, + { 1.234321234321234e26, "1.234321e+26" }, + { 1.234321234321234e27, "1.234321e+27" }, + { 1.234321234321234e28, "1.234321e+28" }, + { 1.234321234321234e29, "1.234321e+29" }, + { 1.234321234321234e30, "1.234321e+30" }, + { 1.234321234321234e31, "1.234321e+31" }, + { 1.234321234321234e32, "1.234321e+32" }, + { 1.234321234321234e33, "1.234321e+33" }, + { 1.234321234321234e34, "1.234321e+34" }, + { 1.234321234321234e35, "1.234321e+35" }, + { 1.234321234321234e36, "1.234321e+36" } }; size_t k; for (k = 0; k < SIZEOF (data); k++) { - char result[100]; - int retval = - my_snprintf (result, sizeof (result), "%e", data[k].value); - const char *expected = data[k].string; - ASSERT (strcmp (result, expected) == 0 - /* Some implementations produce exponents with 3 digits. */ - || (strlen (result) == strlen (expected) + 1 - && memcmp (result, expected, strlen (expected) - 2) == 0 - && result[strlen (expected) - 2] == '0' - && strcmp (result + strlen (expected) - 1, - expected + strlen (expected) - 2) - == 0)); - ASSERT (retval == strlen (result)); + char result[100]; + int retval = + my_snprintf (result, sizeof (result), "%e", data[k].value); + const char *expected = data[k].string; + ASSERT (strcmp (result, expected) == 0 + /* Some implementations produce exponents with 3 digits. */ + || (strlen (result) == strlen (expected) + 1 + && memcmp (result, expected, strlen (expected) - 2) == 0 + && result[strlen (expected) - 2] == '0' + && strcmp (result + strlen (expected) - 1, + expected + strlen (expected) - 2) + == 0)); + ASSERT (retval == strlen (result)); } } @@ -1722,7 +1722,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%e %d", -0.03125, 33, 44, 55); ASSERT (strcmp (result, "-3.125000e-02 33") == 0 - || strcmp (result, "-3.125000e-002 33") == 0); + || strcmp (result, "-3.125000e-002 33") == 0); ASSERT (retval == strlen (result)); } @@ -1731,7 +1731,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%e %d", 0.0, 33, 44, 55); ASSERT (strcmp (result, "0.000000e+00 33") == 0 - || strcmp (result, "0.000000e+000 33") == 0); + || strcmp (result, "0.000000e+000 33") == 0); ASSERT (retval == strlen (result)); } @@ -1741,7 +1741,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) my_snprintf (result, sizeof (result), "%e %d", -zerod, 33, 44, 55); if (have_minus_zero ()) ASSERT (strcmp (result, "-0.000000e+00 33") == 0 - || strcmp (result, "-0.000000e+000 33") == 0); + || strcmp (result, "-0.000000e+000 33") == 0); ASSERT (retval == strlen (result)); } @@ -1750,7 +1750,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%e %d", 1.0 / 0.0, 33, 44, 55); ASSERT (strcmp (result, "inf 33") == 0 - || strcmp (result, "infinity 33") == 0); + || strcmp (result, "infinity 33") == 0); ASSERT (retval == strlen (result)); } @@ -1759,7 +1759,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%e %d", -1.0 / 0.0, 33, 44, 55); ASSERT (strcmp (result, "-inf 33") == 0 - || strcmp (result, "-infinity 33") == 0); + || strcmp (result, "-infinity 33") == 0); ASSERT (retval == strlen (result)); } @@ -1768,8 +1768,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%e %d", NaNd (), 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && strisnan (result, 0, strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -1778,7 +1778,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%15e %d", 1.75, 33, 44, 55); ASSERT (strcmp (result, " 1.750000e+00 33") == 0 - || strcmp (result, " 1.750000e+000 33") == 0); + || strcmp (result, " 1.750000e+000 33") == 0); ASSERT (retval == strlen (result)); } @@ -1787,7 +1787,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%-15e %d", 1.75, 33, 44, 55); ASSERT (strcmp (result, "1.750000e+00 33") == 0 - || strcmp (result, "1.750000e+000 33") == 0); + || strcmp (result, "1.750000e+000 33") == 0); ASSERT (retval == strlen (result)); } @@ -1796,7 +1796,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%+e %d", 1.75, 33, 44, 55); ASSERT (strcmp (result, "+1.750000e+00 33") == 0 - || strcmp (result, "+1.750000e+000 33") == 0); + || strcmp (result, "+1.750000e+000 33") == 0); ASSERT (retval == strlen (result)); } @@ -1805,7 +1805,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "% e %d", 1.75, 33, 44, 55); ASSERT (strcmp (result, " 1.750000e+00 33") == 0 - || strcmp (result, " 1.750000e+000 33") == 0); + || strcmp (result, " 1.750000e+000 33") == 0); ASSERT (retval == strlen (result)); } @@ -1814,7 +1814,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%#e %d", 1.75, 33, 44, 55); ASSERT (strcmp (result, "1.750000e+00 33") == 0 - || strcmp (result, "1.750000e+000 33") == 0); + || strcmp (result, "1.750000e+000 33") == 0); ASSERT (retval == strlen (result)); } @@ -1823,7 +1823,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%#.e %d", 1.75, 33, 44, 55); ASSERT (strcmp (result, "2.e+00 33") == 0 - || strcmp (result, "2.e+000 33") == 0); + || strcmp (result, "2.e+000 33") == 0); ASSERT (retval == strlen (result)); } @@ -1832,7 +1832,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%#.e %d", 9.75, 33, 44, 55); ASSERT (strcmp (result, "1.e+01 33") == 0 - || strcmp (result, "1.e+001 33") == 0); + || strcmp (result, "1.e+001 33") == 0); ASSERT (retval == strlen (result)); } @@ -1841,7 +1841,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%015e %d", 1234.0, 33, 44, 55); ASSERT (strcmp (result, "0001.234000e+03 33") == 0 - || strcmp (result, "001.234000e+003 33") == 0); + || strcmp (result, "001.234000e+003 33") == 0); ASSERT (retval == strlen (result)); } @@ -1850,7 +1850,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%015e %d", -1.0 / 0.0, 33, 44, 55); ASSERT (strcmp (result, " -inf 33") == 0 - || strcmp (result, " -infinity 33") == 0); + || strcmp (result, " -infinity 33") == 0); ASSERT (retval == strlen (result)); } @@ -1859,8 +1859,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%050e %d", NaNd (), 33, 44, 55); ASSERT (strlen (result) == 50 + 3 - && strisnan (result, strspn (result, " "), strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, strspn (result, " "), strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -1869,7 +1869,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%.e %d", 1234.0, 33, 44, 55); ASSERT (strcmp (result, "1e+03 33") == 0 - || strcmp (result, "1e+003 33") == 0); + || strcmp (result, "1e+003 33") == 0); ASSERT (retval == strlen (result)); } @@ -1878,7 +1878,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%.4e %d", 999.951, 33, 44, 55); ASSERT (strcmp (result, "9.9995e+02 33") == 0 - || strcmp (result, "9.9995e+002 33") == 0); + || strcmp (result, "9.9995e+002 33") == 0); ASSERT (retval == strlen (result)); } @@ -1887,7 +1887,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%.4e %d", 999.996, 33, 44, 55); ASSERT (strcmp (result, "1.0000e+03 33") == 0 - || strcmp (result, "1.0000e+003 33") == 0); + || strcmp (result, "1.0000e+003 33") == 0); ASSERT (retval == strlen (result)); } @@ -1896,7 +1896,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%Le %d", 12.75L, 33, 44, 55); ASSERT (strcmp (result, "1.275000e+01 33") == 0 - || strcmp (result, "1.275000e+001 33") == 0); + || strcmp (result, "1.275000e+001 33") == 0); ASSERT (retval == strlen (result)); } @@ -1905,104 +1905,104 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%Le %d", 1234567.0L, 33, 44, 55); ASSERT (strcmp (result, "1.234567e+06 33") == 0 - || strcmp (result, "1.234567e+006 33") == 0); + || strcmp (result, "1.234567e+006 33") == 0); ASSERT (retval == strlen (result)); } { /* Small and large positive numbers. */ static struct { long double value; const char *string; } data[] = { - { 1.234321234321234e-37L, "1.234321e-37" }, - { 1.234321234321234e-36L, "1.234321e-36" }, - { 1.234321234321234e-35L, "1.234321e-35" }, - { 1.234321234321234e-34L, "1.234321e-34" }, - { 1.234321234321234e-33L, "1.234321e-33" }, - { 1.234321234321234e-32L, "1.234321e-32" }, - { 1.234321234321234e-31L, "1.234321e-31" }, - { 1.234321234321234e-30L, "1.234321e-30" }, - { 1.234321234321234e-29L, "1.234321e-29" }, - { 1.234321234321234e-28L, "1.234321e-28" }, - { 1.234321234321234e-27L, "1.234321e-27" }, - { 1.234321234321234e-26L, "1.234321e-26" }, - { 1.234321234321234e-25L, "1.234321e-25" }, - { 1.234321234321234e-24L, "1.234321e-24" }, - { 1.234321234321234e-23L, "1.234321e-23" }, - { 1.234321234321234e-22L, "1.234321e-22" }, - { 1.234321234321234e-21L, "1.234321e-21" }, - { 1.234321234321234e-20L, "1.234321e-20" }, - { 1.234321234321234e-19L, "1.234321e-19" }, - { 1.234321234321234e-18L, "1.234321e-18" }, - { 1.234321234321234e-17L, "1.234321e-17" }, - { 1.234321234321234e-16L, "1.234321e-16" }, - { 1.234321234321234e-15L, "1.234321e-15" }, - { 1.234321234321234e-14L, "1.234321e-14" }, - { 1.234321234321234e-13L, "1.234321e-13" }, - { 1.234321234321234e-12L, "1.234321e-12" }, - { 1.234321234321234e-11L, "1.234321e-11" }, - { 1.234321234321234e-10L, "1.234321e-10" }, - { 1.234321234321234e-9L, "1.234321e-09" }, - { 1.234321234321234e-8L, "1.234321e-08" }, - { 1.234321234321234e-7L, "1.234321e-07" }, - { 1.234321234321234e-6L, "1.234321e-06" }, - { 1.234321234321234e-5L, "1.234321e-05" }, - { 1.234321234321234e-4L, "1.234321e-04" }, - { 1.234321234321234e-3L, "1.234321e-03" }, - { 1.234321234321234e-2L, "1.234321e-02" }, - { 1.234321234321234e-1L, "1.234321e-01" }, - { 1.234321234321234L, "1.234321e+00" }, - { 1.234321234321234e1L, "1.234321e+01" }, - { 1.234321234321234e2L, "1.234321e+02" }, - { 1.234321234321234e3L, "1.234321e+03" }, - { 1.234321234321234e4L, "1.234321e+04" }, - { 1.234321234321234e5L, "1.234321e+05" }, - { 1.234321234321234e6L, "1.234321e+06" }, - { 1.234321234321234e7L, "1.234321e+07" }, - { 1.234321234321234e8L, "1.234321e+08" }, - { 1.234321234321234e9L, "1.234321e+09" }, - { 1.234321234321234e10L, "1.234321e+10" }, - { 1.234321234321234e11L, "1.234321e+11" }, - { 1.234321234321234e12L, "1.234321e+12" }, - { 1.234321234321234e13L, "1.234321e+13" }, - { 1.234321234321234e14L, "1.234321e+14" }, - { 1.234321234321234e15L, "1.234321e+15" }, - { 1.234321234321234e16L, "1.234321e+16" }, - { 1.234321234321234e17L, "1.234321e+17" }, - { 1.234321234321234e18L, "1.234321e+18" }, - { 1.234321234321234e19L, "1.234321e+19" }, - { 1.234321234321234e20L, "1.234321e+20" }, - { 1.234321234321234e21L, "1.234321e+21" }, - { 1.234321234321234e22L, "1.234321e+22" }, - { 1.234321234321234e23L, "1.234321e+23" }, - { 1.234321234321234e24L, "1.234321e+24" }, - { 1.234321234321234e25L, "1.234321e+25" }, - { 1.234321234321234e26L, "1.234321e+26" }, - { 1.234321234321234e27L, "1.234321e+27" }, - { 1.234321234321234e28L, "1.234321e+28" }, - { 1.234321234321234e29L, "1.234321e+29" }, - { 1.234321234321234e30L, "1.234321e+30" }, - { 1.234321234321234e31L, "1.234321e+31" }, - { 1.234321234321234e32L, "1.234321e+32" }, - { 1.234321234321234e33L, "1.234321e+33" }, - { 1.234321234321234e34L, "1.234321e+34" }, - { 1.234321234321234e35L, "1.234321e+35" }, - { 1.234321234321234e36L, "1.234321e+36" } + { 1.234321234321234e-37L, "1.234321e-37" }, + { 1.234321234321234e-36L, "1.234321e-36" }, + { 1.234321234321234e-35L, "1.234321e-35" }, + { 1.234321234321234e-34L, "1.234321e-34" }, + { 1.234321234321234e-33L, "1.234321e-33" }, + { 1.234321234321234e-32L, "1.234321e-32" }, + { 1.234321234321234e-31L, "1.234321e-31" }, + { 1.234321234321234e-30L, "1.234321e-30" }, + { 1.234321234321234e-29L, "1.234321e-29" }, + { 1.234321234321234e-28L, "1.234321e-28" }, + { 1.234321234321234e-27L, "1.234321e-27" }, + { 1.234321234321234e-26L, "1.234321e-26" }, + { 1.234321234321234e-25L, "1.234321e-25" }, + { 1.234321234321234e-24L, "1.234321e-24" }, + { 1.234321234321234e-23L, "1.234321e-23" }, + { 1.234321234321234e-22L, "1.234321e-22" }, + { 1.234321234321234e-21L, "1.234321e-21" }, + { 1.234321234321234e-20L, "1.234321e-20" }, + { 1.234321234321234e-19L, "1.234321e-19" }, + { 1.234321234321234e-18L, "1.234321e-18" }, + { 1.234321234321234e-17L, "1.234321e-17" }, + { 1.234321234321234e-16L, "1.234321e-16" }, + { 1.234321234321234e-15L, "1.234321e-15" }, + { 1.234321234321234e-14L, "1.234321e-14" }, + { 1.234321234321234e-13L, "1.234321e-13" }, + { 1.234321234321234e-12L, "1.234321e-12" }, + { 1.234321234321234e-11L, "1.234321e-11" }, + { 1.234321234321234e-10L, "1.234321e-10" }, + { 1.234321234321234e-9L, "1.234321e-09" }, + { 1.234321234321234e-8L, "1.234321e-08" }, + { 1.234321234321234e-7L, "1.234321e-07" }, + { 1.234321234321234e-6L, "1.234321e-06" }, + { 1.234321234321234e-5L, "1.234321e-05" }, + { 1.234321234321234e-4L, "1.234321e-04" }, + { 1.234321234321234e-3L, "1.234321e-03" }, + { 1.234321234321234e-2L, "1.234321e-02" }, + { 1.234321234321234e-1L, "1.234321e-01" }, + { 1.234321234321234L, "1.234321e+00" }, + { 1.234321234321234e1L, "1.234321e+01" }, + { 1.234321234321234e2L, "1.234321e+02" }, + { 1.234321234321234e3L, "1.234321e+03" }, + { 1.234321234321234e4L, "1.234321e+04" }, + { 1.234321234321234e5L, "1.234321e+05" }, + { 1.234321234321234e6L, "1.234321e+06" }, + { 1.234321234321234e7L, "1.234321e+07" }, + { 1.234321234321234e8L, "1.234321e+08" }, + { 1.234321234321234e9L, "1.234321e+09" }, + { 1.234321234321234e10L, "1.234321e+10" }, + { 1.234321234321234e11L, "1.234321e+11" }, + { 1.234321234321234e12L, "1.234321e+12" }, + { 1.234321234321234e13L, "1.234321e+13" }, + { 1.234321234321234e14L, "1.234321e+14" }, + { 1.234321234321234e15L, "1.234321e+15" }, + { 1.234321234321234e16L, "1.234321e+16" }, + { 1.234321234321234e17L, "1.234321e+17" }, + { 1.234321234321234e18L, "1.234321e+18" }, + { 1.234321234321234e19L, "1.234321e+19" }, + { 1.234321234321234e20L, "1.234321e+20" }, + { 1.234321234321234e21L, "1.234321e+21" }, + { 1.234321234321234e22L, "1.234321e+22" }, + { 1.234321234321234e23L, "1.234321e+23" }, + { 1.234321234321234e24L, "1.234321e+24" }, + { 1.234321234321234e25L, "1.234321e+25" }, + { 1.234321234321234e26L, "1.234321e+26" }, + { 1.234321234321234e27L, "1.234321e+27" }, + { 1.234321234321234e28L, "1.234321e+28" }, + { 1.234321234321234e29L, "1.234321e+29" }, + { 1.234321234321234e30L, "1.234321e+30" }, + { 1.234321234321234e31L, "1.234321e+31" }, + { 1.234321234321234e32L, "1.234321e+32" }, + { 1.234321234321234e33L, "1.234321e+33" }, + { 1.234321234321234e34L, "1.234321e+34" }, + { 1.234321234321234e35L, "1.234321e+35" }, + { 1.234321234321234e36L, "1.234321e+36" } }; size_t k; for (k = 0; k < SIZEOF (data); k++) { - char result[100]; - int retval = - my_snprintf (result, sizeof (result), "%Le", data[k].value); - const char *expected = data[k].string; - ASSERT (strcmp (result, expected) == 0 - /* Some implementations produce exponents with 3 digits. */ - || (strlen (result) == strlen (expected) + 1 - && memcmp (result, expected, strlen (expected) - 2) == 0 - && result[strlen (expected) - 2] == '0' - && strcmp (result + strlen (expected) - 1, - expected + strlen (expected) - 2) - == 0)); - ASSERT (retval == strlen (result)); + char result[100]; + int retval = + my_snprintf (result, sizeof (result), "%Le", data[k].value); + const char *expected = data[k].string; + ASSERT (strcmp (result, expected) == 0 + /* Some implementations produce exponents with 3 digits. */ + || (strlen (result) == strlen (expected) + 1 + && memcmp (result, expected, strlen (expected) - 2) == 0 + && result[strlen (expected) - 2] == '0' + && strcmp (result + strlen (expected) - 1, + expected + strlen (expected) - 2) + == 0)); + ASSERT (retval == strlen (result)); } } @@ -2011,7 +2011,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%Le %d", -0.03125L, 33, 44, 55); ASSERT (strcmp (result, "-3.125000e-02 33") == 0 - || strcmp (result, "-3.125000e-002 33") == 0); + || strcmp (result, "-3.125000e-002 33") == 0); ASSERT (retval == strlen (result)); } @@ -2020,7 +2020,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%Le %d", 0.0L, 33, 44, 55); ASSERT (strcmp (result, "0.000000e+00 33") == 0 - || strcmp (result, "0.000000e+000 33") == 0); + || strcmp (result, "0.000000e+000 33") == 0); ASSERT (retval == strlen (result)); } @@ -2030,7 +2030,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) my_snprintf (result, sizeof (result), "%Le %d", minus_zerol, 33, 44, 55); if (have_minus_zero ()) ASSERT (strcmp (result, "-0.000000e+00 33") == 0 - || strcmp (result, "-0.000000e+000 33") == 0); + || strcmp (result, "-0.000000e+000 33") == 0); ASSERT (retval == strlen (result)); } @@ -2039,7 +2039,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%Le %d", 1.0L / 0.0L, 33, 44, 55); ASSERT (strcmp (result, "inf 33") == 0 - || strcmp (result, "infinity 33") == 0); + || strcmp (result, "infinity 33") == 0); ASSERT (retval == strlen (result)); } @@ -2048,7 +2048,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%Le %d", -1.0L / 0.0L, 33, 44, 55); ASSERT (strcmp (result, "-inf 33") == 0 - || strcmp (result, "-infinity 33") == 0); + || strcmp (result, "-infinity 33") == 0); ASSERT (retval == strlen (result)); } @@ -2057,8 +2057,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%Le %d", NaNl (), 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && strisnan (result, 0, strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } #if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) @@ -2069,8 +2069,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%Le %d", x.value, 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && strisnan (result, 0, strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } { @@ -2081,8 +2081,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%Le %d", x.value, 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && strisnan (result, 0, strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } /* The isnanl function should recognize Pseudo-NaNs, Pseudo-Infinities, @@ -2099,8 +2099,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%Le %d", x.value, 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && strisnan (result, 0, strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } { /* Pseudo-Infinity. */ @@ -2110,8 +2110,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%Le %d", x.value, 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && strisnan (result, 0, strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } { /* Pseudo-Zero. */ @@ -2121,8 +2121,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%Le %d", x.value, 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && strisnan (result, 0, strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } { /* Unnormalized number. */ @@ -2132,8 +2132,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%Le %d", x.value, 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && strisnan (result, 0, strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } { /* Pseudo-Denormal. */ @@ -2143,8 +2143,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%Le %d", x.value, 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && strisnan (result, 0, strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } #endif @@ -2154,7 +2154,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%15Le %d", 1.75L, 33, 44, 55); ASSERT (strcmp (result, " 1.750000e+00 33") == 0 - || strcmp (result, " 1.750000e+000 33") == 0); + || strcmp (result, " 1.750000e+000 33") == 0); ASSERT (retval == strlen (result)); } @@ -2163,7 +2163,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%-15Le %d", 1.75L, 33, 44, 55); ASSERT (strcmp (result, "1.750000e+00 33") == 0 - || strcmp (result, "1.750000e+000 33") == 0); + || strcmp (result, "1.750000e+000 33") == 0); ASSERT (retval == strlen (result)); } @@ -2172,7 +2172,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%+Le %d", 1.75L, 33, 44, 55); ASSERT (strcmp (result, "+1.750000e+00 33") == 0 - || strcmp (result, "+1.750000e+000 33") == 0); + || strcmp (result, "+1.750000e+000 33") == 0); ASSERT (retval == strlen (result)); } @@ -2181,7 +2181,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "% Le %d", 1.75L, 33, 44, 55); ASSERT (strcmp (result, " 1.750000e+00 33") == 0 - || strcmp (result, " 1.750000e+000 33") == 0); + || strcmp (result, " 1.750000e+000 33") == 0); ASSERT (retval == strlen (result)); } @@ -2190,7 +2190,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%#Le %d", 1.75L, 33, 44, 55); ASSERT (strcmp (result, "1.750000e+00 33") == 0 - || strcmp (result, "1.750000e+000 33") == 0); + || strcmp (result, "1.750000e+000 33") == 0); ASSERT (retval == strlen (result)); } @@ -2199,7 +2199,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%#.Le %d", 1.75L, 33, 44, 55); ASSERT (strcmp (result, "2.e+00 33") == 0 - || strcmp (result, "2.e+000 33") == 0); + || strcmp (result, "2.e+000 33") == 0); ASSERT (retval == strlen (result)); } @@ -2208,7 +2208,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%#.Le %d", 9.75L, 33, 44, 55); ASSERT (strcmp (result, "1.e+01 33") == 0 - || strcmp (result, "1.e+001 33") == 0); + || strcmp (result, "1.e+001 33") == 0); ASSERT (retval == strlen (result)); } @@ -2217,7 +2217,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%015Le %d", 1234.0L, 33, 44, 55); ASSERT (strcmp (result, "0001.234000e+03 33") == 0 - || strcmp (result, "001.234000e+003 33") == 0); + || strcmp (result, "001.234000e+003 33") == 0); ASSERT (retval == strlen (result)); } @@ -2226,7 +2226,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%015Le %d", -1.0L / 0.0L, 33, 44, 55); ASSERT (strcmp (result, " -inf 33") == 0 - || strcmp (result, " -infinity 33") == 0); + || strcmp (result, " -infinity 33") == 0); ASSERT (retval == strlen (result)); } @@ -2235,8 +2235,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%050Le %d", NaNl (), 33, 44, 55); ASSERT (strlen (result) == 50 + 3 - && strisnan (result, strspn (result, " "), strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, strspn (result, " "), strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -2245,7 +2245,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%.Le %d", 1234.0L, 33, 44, 55); ASSERT (strcmp (result, "1e+03 33") == 0 - || strcmp (result, "1e+003 33") == 0); + || strcmp (result, "1e+003 33") == 0); ASSERT (retval == strlen (result)); } @@ -2254,7 +2254,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%.4Le %d", 999.951L, 33, 44, 55); ASSERT (strcmp (result, "9.9995e+02 33") == 0 - || strcmp (result, "9.9995e+002 33") == 0); + || strcmp (result, "9.9995e+002 33") == 0); ASSERT (retval == strlen (result)); } @@ -2263,7 +2263,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%.4Le %d", 999.996L, 33, 44, 55); ASSERT (strcmp (result, "1.0000e+03 33") == 0 - || strcmp (result, "1.0000e+003 33") == 0); + || strcmp (result, "1.0000e+003 33") == 0); ASSERT (retval == strlen (result)); } @@ -2282,105 +2282,105 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%g %d", 1234567.0, 33, 44, 55); ASSERT (strcmp (result, "1.23457e+06 33") == 0 - || strcmp (result, "1.23457e+006 33") == 0); + || strcmp (result, "1.23457e+006 33") == 0); ASSERT (retval == strlen (result)); } { /* Small and large positive numbers. */ static struct { double value; const char *string; } data[] = { - { 1.234321234321234e-37, "1.23432e-37" }, - { 1.234321234321234e-36, "1.23432e-36" }, - { 1.234321234321234e-35, "1.23432e-35" }, - { 1.234321234321234e-34, "1.23432e-34" }, - { 1.234321234321234e-33, "1.23432e-33" }, - { 1.234321234321234e-32, "1.23432e-32" }, - { 1.234321234321234e-31, "1.23432e-31" }, - { 1.234321234321234e-30, "1.23432e-30" }, - { 1.234321234321234e-29, "1.23432e-29" }, - { 1.234321234321234e-28, "1.23432e-28" }, - { 1.234321234321234e-27, "1.23432e-27" }, - { 1.234321234321234e-26, "1.23432e-26" }, - { 1.234321234321234e-25, "1.23432e-25" }, - { 1.234321234321234e-24, "1.23432e-24" }, - { 1.234321234321234e-23, "1.23432e-23" }, - { 1.234321234321234e-22, "1.23432e-22" }, - { 1.234321234321234e-21, "1.23432e-21" }, - { 1.234321234321234e-20, "1.23432e-20" }, - { 1.234321234321234e-19, "1.23432e-19" }, - { 1.234321234321234e-18, "1.23432e-18" }, - { 1.234321234321234e-17, "1.23432e-17" }, - { 1.234321234321234e-16, "1.23432e-16" }, - { 1.234321234321234e-15, "1.23432e-15" }, - { 1.234321234321234e-14, "1.23432e-14" }, - { 1.234321234321234e-13, "1.23432e-13" }, - { 1.234321234321234e-12, "1.23432e-12" }, - { 1.234321234321234e-11, "1.23432e-11" }, - { 1.234321234321234e-10, "1.23432e-10" }, - { 1.234321234321234e-9, "1.23432e-09" }, - { 1.234321234321234e-8, "1.23432e-08" }, - { 1.234321234321234e-7, "1.23432e-07" }, - { 1.234321234321234e-6, "1.23432e-06" }, - { 1.234321234321234e-5, "1.23432e-05" }, - { 1.234321234321234e-4, "0.000123432" }, - { 1.234321234321234e-3, "0.00123432" }, - { 1.234321234321234e-2, "0.0123432" }, - { 1.234321234321234e-1, "0.123432" }, - { 1.234321234321234, "1.23432" }, - { 1.234321234321234e1, "12.3432" }, - { 1.234321234321234e2, "123.432" }, - { 1.234321234321234e3, "1234.32" }, - { 1.234321234321234e4, "12343.2" }, - { 1.234321234321234e5, "123432" }, - { 1.234321234321234e6, "1.23432e+06" }, - { 1.234321234321234e7, "1.23432e+07" }, - { 1.234321234321234e8, "1.23432e+08" }, - { 1.234321234321234e9, "1.23432e+09" }, - { 1.234321234321234e10, "1.23432e+10" }, - { 1.234321234321234e11, "1.23432e+11" }, - { 1.234321234321234e12, "1.23432e+12" }, - { 1.234321234321234e13, "1.23432e+13" }, - { 1.234321234321234e14, "1.23432e+14" }, - { 1.234321234321234e15, "1.23432e+15" }, - { 1.234321234321234e16, "1.23432e+16" }, - { 1.234321234321234e17, "1.23432e+17" }, - { 1.234321234321234e18, "1.23432e+18" }, - { 1.234321234321234e19, "1.23432e+19" }, - { 1.234321234321234e20, "1.23432e+20" }, - { 1.234321234321234e21, "1.23432e+21" }, - { 1.234321234321234e22, "1.23432e+22" }, - { 1.234321234321234e23, "1.23432e+23" }, - { 1.234321234321234e24, "1.23432e+24" }, - { 1.234321234321234e25, "1.23432e+25" }, - { 1.234321234321234e26, "1.23432e+26" }, - { 1.234321234321234e27, "1.23432e+27" }, - { 1.234321234321234e28, "1.23432e+28" }, - { 1.234321234321234e29, "1.23432e+29" }, - { 1.234321234321234e30, "1.23432e+30" }, - { 1.234321234321234e31, "1.23432e+31" }, - { 1.234321234321234e32, "1.23432e+32" }, - { 1.234321234321234e33, "1.23432e+33" }, - { 1.234321234321234e34, "1.23432e+34" }, - { 1.234321234321234e35, "1.23432e+35" }, - { 1.234321234321234e36, "1.23432e+36" } + { 1.234321234321234e-37, "1.23432e-37" }, + { 1.234321234321234e-36, "1.23432e-36" }, + { 1.234321234321234e-35, "1.23432e-35" }, + { 1.234321234321234e-34, "1.23432e-34" }, + { 1.234321234321234e-33, "1.23432e-33" }, + { 1.234321234321234e-32, "1.23432e-32" }, + { 1.234321234321234e-31, "1.23432e-31" }, + { 1.234321234321234e-30, "1.23432e-30" }, + { 1.234321234321234e-29, "1.23432e-29" }, + { 1.234321234321234e-28, "1.23432e-28" }, + { 1.234321234321234e-27, "1.23432e-27" }, + { 1.234321234321234e-26, "1.23432e-26" }, + { 1.234321234321234e-25, "1.23432e-25" }, + { 1.234321234321234e-24, "1.23432e-24" }, + { 1.234321234321234e-23, "1.23432e-23" }, + { 1.234321234321234e-22, "1.23432e-22" }, + { 1.234321234321234e-21, "1.23432e-21" }, + { 1.234321234321234e-20, "1.23432e-20" }, + { 1.234321234321234e-19, "1.23432e-19" }, + { 1.234321234321234e-18, "1.23432e-18" }, + { 1.234321234321234e-17, "1.23432e-17" }, + { 1.234321234321234e-16, "1.23432e-16" }, + { 1.234321234321234e-15, "1.23432e-15" }, + { 1.234321234321234e-14, "1.23432e-14" }, + { 1.234321234321234e-13, "1.23432e-13" }, + { 1.234321234321234e-12, "1.23432e-12" }, + { 1.234321234321234e-11, "1.23432e-11" }, + { 1.234321234321234e-10, "1.23432e-10" }, + { 1.234321234321234e-9, "1.23432e-09" }, + { 1.234321234321234e-8, "1.23432e-08" }, + { 1.234321234321234e-7, "1.23432e-07" }, + { 1.234321234321234e-6, "1.23432e-06" }, + { 1.234321234321234e-5, "1.23432e-05" }, + { 1.234321234321234e-4, "0.000123432" }, + { 1.234321234321234e-3, "0.00123432" }, + { 1.234321234321234e-2, "0.0123432" }, + { 1.234321234321234e-1, "0.123432" }, + { 1.234321234321234, "1.23432" }, + { 1.234321234321234e1, "12.3432" }, + { 1.234321234321234e2, "123.432" }, + { 1.234321234321234e3, "1234.32" }, + { 1.234321234321234e4, "12343.2" }, + { 1.234321234321234e5, "123432" }, + { 1.234321234321234e6, "1.23432e+06" }, + { 1.234321234321234e7, "1.23432e+07" }, + { 1.234321234321234e8, "1.23432e+08" }, + { 1.234321234321234e9, "1.23432e+09" }, + { 1.234321234321234e10, "1.23432e+10" }, + { 1.234321234321234e11, "1.23432e+11" }, + { 1.234321234321234e12, "1.23432e+12" }, + { 1.234321234321234e13, "1.23432e+13" }, + { 1.234321234321234e14, "1.23432e+14" }, + { 1.234321234321234e15, "1.23432e+15" }, + { 1.234321234321234e16, "1.23432e+16" }, + { 1.234321234321234e17, "1.23432e+17" }, + { 1.234321234321234e18, "1.23432e+18" }, + { 1.234321234321234e19, "1.23432e+19" }, + { 1.234321234321234e20, "1.23432e+20" }, + { 1.234321234321234e21, "1.23432e+21" }, + { 1.234321234321234e22, "1.23432e+22" }, + { 1.234321234321234e23, "1.23432e+23" }, + { 1.234321234321234e24, "1.23432e+24" }, + { 1.234321234321234e25, "1.23432e+25" }, + { 1.234321234321234e26, "1.23432e+26" }, + { 1.234321234321234e27, "1.23432e+27" }, + { 1.234321234321234e28, "1.23432e+28" }, + { 1.234321234321234e29, "1.23432e+29" }, + { 1.234321234321234e30, "1.23432e+30" }, + { 1.234321234321234e31, "1.23432e+31" }, + { 1.234321234321234e32, "1.23432e+32" }, + { 1.234321234321234e33, "1.23432e+33" }, + { 1.234321234321234e34, "1.23432e+34" }, + { 1.234321234321234e35, "1.23432e+35" }, + { 1.234321234321234e36, "1.23432e+36" } }; size_t k; for (k = 0; k < SIZEOF (data); k++) { - char result[100]; - int retval = - my_snprintf (result, sizeof (result), "%g", data[k].value); - const char *expected = data[k].string; - ASSERT (strcmp (result, expected) == 0 - /* Some implementations produce exponents with 3 digits. */ - || (expected[strlen (expected) - 4] == 'e' - && strlen (result) == strlen (expected) + 1 - && memcmp (result, expected, strlen (expected) - 2) == 0 - && result[strlen (expected) - 2] == '0' - && strcmp (result + strlen (expected) - 1, - expected + strlen (expected) - 2) - == 0)); - ASSERT (retval == strlen (result)); + char result[100]; + int retval = + my_snprintf (result, sizeof (result), "%g", data[k].value); + const char *expected = data[k].string; + ASSERT (strcmp (result, expected) == 0 + /* Some implementations produce exponents with 3 digits. */ + || (expected[strlen (expected) - 4] == 'e' + && strlen (result) == strlen (expected) + 1 + && memcmp (result, expected, strlen (expected) - 2) == 0 + && result[strlen (expected) - 2] == '0' + && strcmp (result + strlen (expected) - 1, + expected + strlen (expected) - 2) + == 0)); + ASSERT (retval == strlen (result)); } } @@ -2414,7 +2414,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%g %d", 1.0 / 0.0, 33, 44, 55); ASSERT (strcmp (result, "inf 33") == 0 - || strcmp (result, "infinity 33") == 0); + || strcmp (result, "infinity 33") == 0); ASSERT (retval == strlen (result)); } @@ -2423,7 +2423,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%g %d", -1.0 / 0.0, 33, 44, 55); ASSERT (strcmp (result, "-inf 33") == 0 - || strcmp (result, "-infinity 33") == 0); + || strcmp (result, "-infinity 33") == 0); ASSERT (retval == strlen (result)); } @@ -2432,8 +2432,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%g %d", NaNd (), 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && strisnan (result, 0, strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -2490,7 +2490,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%#.g %d", 9.75, 33, 44, 55); ASSERT (strcmp (result, "1.e+01 33") == 0 - || strcmp (result, "1.e+001 33") == 0); + || strcmp (result, "1.e+001 33") == 0); ASSERT (retval == strlen (result)); } @@ -2507,7 +2507,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%015g %d", -1.0 / 0.0, 33, 44, 55); ASSERT (strcmp (result, " -inf 33") == 0 - || strcmp (result, " -infinity 33") == 0); + || strcmp (result, " -infinity 33") == 0); ASSERT (retval == strlen (result)); } @@ -2516,8 +2516,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%050g %d", NaNd (), 33, 44, 55); ASSERT (strlen (result) == 50 + 3 - && strisnan (result, strspn (result, " "), strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, strspn (result, " "), strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -2526,7 +2526,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%.g %d", 1234.0, 33, 44, 55); ASSERT (strcmp (result, "1e+03 33") == 0 - || strcmp (result, "1e+003 33") == 0); + || strcmp (result, "1e+003 33") == 0); ASSERT (retval == strlen (result)); } @@ -2559,105 +2559,105 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%Lg %d", 1234567.0L, 33, 44, 55); ASSERT (strcmp (result, "1.23457e+06 33") == 0 - || strcmp (result, "1.23457e+006 33") == 0); + || strcmp (result, "1.23457e+006 33") == 0); ASSERT (retval == strlen (result)); } { /* Small and large positive numbers. */ static struct { long double value; const char *string; } data[] = { - { 1.234321234321234e-37L, "1.23432e-37" }, - { 1.234321234321234e-36L, "1.23432e-36" }, - { 1.234321234321234e-35L, "1.23432e-35" }, - { 1.234321234321234e-34L, "1.23432e-34" }, - { 1.234321234321234e-33L, "1.23432e-33" }, - { 1.234321234321234e-32L, "1.23432e-32" }, - { 1.234321234321234e-31L, "1.23432e-31" }, - { 1.234321234321234e-30L, "1.23432e-30" }, - { 1.234321234321234e-29L, "1.23432e-29" }, - { 1.234321234321234e-28L, "1.23432e-28" }, - { 1.234321234321234e-27L, "1.23432e-27" }, - { 1.234321234321234e-26L, "1.23432e-26" }, - { 1.234321234321234e-25L, "1.23432e-25" }, - { 1.234321234321234e-24L, "1.23432e-24" }, - { 1.234321234321234e-23L, "1.23432e-23" }, - { 1.234321234321234e-22L, "1.23432e-22" }, - { 1.234321234321234e-21L, "1.23432e-21" }, - { 1.234321234321234e-20L, "1.23432e-20" }, - { 1.234321234321234e-19L, "1.23432e-19" }, - { 1.234321234321234e-18L, "1.23432e-18" }, - { 1.234321234321234e-17L, "1.23432e-17" }, - { 1.234321234321234e-16L, "1.23432e-16" }, - { 1.234321234321234e-15L, "1.23432e-15" }, - { 1.234321234321234e-14L, "1.23432e-14" }, - { 1.234321234321234e-13L, "1.23432e-13" }, - { 1.234321234321234e-12L, "1.23432e-12" }, - { 1.234321234321234e-11L, "1.23432e-11" }, - { 1.234321234321234e-10L, "1.23432e-10" }, - { 1.234321234321234e-9L, "1.23432e-09" }, - { 1.234321234321234e-8L, "1.23432e-08" }, - { 1.234321234321234e-7L, "1.23432e-07" }, - { 1.234321234321234e-6L, "1.23432e-06" }, - { 1.234321234321234e-5L, "1.23432e-05" }, - { 1.234321234321234e-4L, "0.000123432" }, - { 1.234321234321234e-3L, "0.00123432" }, - { 1.234321234321234e-2L, "0.0123432" }, - { 1.234321234321234e-1L, "0.123432" }, - { 1.234321234321234L, "1.23432" }, - { 1.234321234321234e1L, "12.3432" }, - { 1.234321234321234e2L, "123.432" }, - { 1.234321234321234e3L, "1234.32" }, - { 1.234321234321234e4L, "12343.2" }, - { 1.234321234321234e5L, "123432" }, - { 1.234321234321234e6L, "1.23432e+06" }, - { 1.234321234321234e7L, "1.23432e+07" }, - { 1.234321234321234e8L, "1.23432e+08" }, - { 1.234321234321234e9L, "1.23432e+09" }, - { 1.234321234321234e10L, "1.23432e+10" }, - { 1.234321234321234e11L, "1.23432e+11" }, - { 1.234321234321234e12L, "1.23432e+12" }, - { 1.234321234321234e13L, "1.23432e+13" }, - { 1.234321234321234e14L, "1.23432e+14" }, - { 1.234321234321234e15L, "1.23432e+15" }, - { 1.234321234321234e16L, "1.23432e+16" }, - { 1.234321234321234e17L, "1.23432e+17" }, - { 1.234321234321234e18L, "1.23432e+18" }, - { 1.234321234321234e19L, "1.23432e+19" }, - { 1.234321234321234e20L, "1.23432e+20" }, - { 1.234321234321234e21L, "1.23432e+21" }, - { 1.234321234321234e22L, "1.23432e+22" }, - { 1.234321234321234e23L, "1.23432e+23" }, - { 1.234321234321234e24L, "1.23432e+24" }, - { 1.234321234321234e25L, "1.23432e+25" }, - { 1.234321234321234e26L, "1.23432e+26" }, - { 1.234321234321234e27L, "1.23432e+27" }, - { 1.234321234321234e28L, "1.23432e+28" }, - { 1.234321234321234e29L, "1.23432e+29" }, - { 1.234321234321234e30L, "1.23432e+30" }, - { 1.234321234321234e31L, "1.23432e+31" }, - { 1.234321234321234e32L, "1.23432e+32" }, - { 1.234321234321234e33L, "1.23432e+33" }, - { 1.234321234321234e34L, "1.23432e+34" }, - { 1.234321234321234e35L, "1.23432e+35" }, - { 1.234321234321234e36L, "1.23432e+36" } + { 1.234321234321234e-37L, "1.23432e-37" }, + { 1.234321234321234e-36L, "1.23432e-36" }, + { 1.234321234321234e-35L, "1.23432e-35" }, + { 1.234321234321234e-34L, "1.23432e-34" }, + { 1.234321234321234e-33L, "1.23432e-33" }, + { 1.234321234321234e-32L, "1.23432e-32" }, + { 1.234321234321234e-31L, "1.23432e-31" }, + { 1.234321234321234e-30L, "1.23432e-30" }, + { 1.234321234321234e-29L, "1.23432e-29" }, + { 1.234321234321234e-28L, "1.23432e-28" }, + { 1.234321234321234e-27L, "1.23432e-27" }, + { 1.234321234321234e-26L, "1.23432e-26" }, + { 1.234321234321234e-25L, "1.23432e-25" }, + { 1.234321234321234e-24L, "1.23432e-24" }, + { 1.234321234321234e-23L, "1.23432e-23" }, + { 1.234321234321234e-22L, "1.23432e-22" }, + { 1.234321234321234e-21L, "1.23432e-21" }, + { 1.234321234321234e-20L, "1.23432e-20" }, + { 1.234321234321234e-19L, "1.23432e-19" }, + { 1.234321234321234e-18L, "1.23432e-18" }, + { 1.234321234321234e-17L, "1.23432e-17" }, + { 1.234321234321234e-16L, "1.23432e-16" }, + { 1.234321234321234e-15L, "1.23432e-15" }, + { 1.234321234321234e-14L, "1.23432e-14" }, + { 1.234321234321234e-13L, "1.23432e-13" }, + { 1.234321234321234e-12L, "1.23432e-12" }, + { 1.234321234321234e-11L, "1.23432e-11" }, + { 1.234321234321234e-10L, "1.23432e-10" }, + { 1.234321234321234e-9L, "1.23432e-09" }, + { 1.234321234321234e-8L, "1.23432e-08" }, + { 1.234321234321234e-7L, "1.23432e-07" }, + { 1.234321234321234e-6L, "1.23432e-06" }, + { 1.234321234321234e-5L, "1.23432e-05" }, + { 1.234321234321234e-4L, "0.000123432" }, + { 1.234321234321234e-3L, "0.00123432" }, + { 1.234321234321234e-2L, "0.0123432" }, + { 1.234321234321234e-1L, "0.123432" }, + { 1.234321234321234L, "1.23432" }, + { 1.234321234321234e1L, "12.3432" }, + { 1.234321234321234e2L, "123.432" }, + { 1.234321234321234e3L, "1234.32" }, + { 1.234321234321234e4L, "12343.2" }, + { 1.234321234321234e5L, "123432" }, + { 1.234321234321234e6L, "1.23432e+06" }, + { 1.234321234321234e7L, "1.23432e+07" }, + { 1.234321234321234e8L, "1.23432e+08" }, + { 1.234321234321234e9L, "1.23432e+09" }, + { 1.234321234321234e10L, "1.23432e+10" }, + { 1.234321234321234e11L, "1.23432e+11" }, + { 1.234321234321234e12L, "1.23432e+12" }, + { 1.234321234321234e13L, "1.23432e+13" }, + { 1.234321234321234e14L, "1.23432e+14" }, + { 1.234321234321234e15L, "1.23432e+15" }, + { 1.234321234321234e16L, "1.23432e+16" }, + { 1.234321234321234e17L, "1.23432e+17" }, + { 1.234321234321234e18L, "1.23432e+18" }, + { 1.234321234321234e19L, "1.23432e+19" }, + { 1.234321234321234e20L, "1.23432e+20" }, + { 1.234321234321234e21L, "1.23432e+21" }, + { 1.234321234321234e22L, "1.23432e+22" }, + { 1.234321234321234e23L, "1.23432e+23" }, + { 1.234321234321234e24L, "1.23432e+24" }, + { 1.234321234321234e25L, "1.23432e+25" }, + { 1.234321234321234e26L, "1.23432e+26" }, + { 1.234321234321234e27L, "1.23432e+27" }, + { 1.234321234321234e28L, "1.23432e+28" }, + { 1.234321234321234e29L, "1.23432e+29" }, + { 1.234321234321234e30L, "1.23432e+30" }, + { 1.234321234321234e31L, "1.23432e+31" }, + { 1.234321234321234e32L, "1.23432e+32" }, + { 1.234321234321234e33L, "1.23432e+33" }, + { 1.234321234321234e34L, "1.23432e+34" }, + { 1.234321234321234e35L, "1.23432e+35" }, + { 1.234321234321234e36L, "1.23432e+36" } }; size_t k; for (k = 0; k < SIZEOF (data); k++) { - char result[100]; - int retval = - my_snprintf (result, sizeof (result), "%Lg", data[k].value); - const char *expected = data[k].string; - ASSERT (strcmp (result, expected) == 0 - /* Some implementations produce exponents with 3 digits. */ - || (expected[strlen (expected) - 4] == 'e' - && strlen (result) == strlen (expected) + 1 - && memcmp (result, expected, strlen (expected) - 2) == 0 - && result[strlen (expected) - 2] == '0' - && strcmp (result + strlen (expected) - 1, - expected + strlen (expected) - 2) - == 0)); - ASSERT (retval == strlen (result)); + char result[100]; + int retval = + my_snprintf (result, sizeof (result), "%Lg", data[k].value); + const char *expected = data[k].string; + ASSERT (strcmp (result, expected) == 0 + /* Some implementations produce exponents with 3 digits. */ + || (expected[strlen (expected) - 4] == 'e' + && strlen (result) == strlen (expected) + 1 + && memcmp (result, expected, strlen (expected) - 2) == 0 + && result[strlen (expected) - 2] == '0' + && strcmp (result + strlen (expected) - 1, + expected + strlen (expected) - 2) + == 0)); + ASSERT (retval == strlen (result)); } } @@ -2691,7 +2691,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%Lg %d", 1.0L / 0.0L, 33, 44, 55); ASSERT (strcmp (result, "inf 33") == 0 - || strcmp (result, "infinity 33") == 0); + || strcmp (result, "infinity 33") == 0); ASSERT (retval == strlen (result)); } @@ -2700,7 +2700,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%Lg %d", -1.0L / 0.0L, 33, 44, 55); ASSERT (strcmp (result, "-inf 33") == 0 - || strcmp (result, "-infinity 33") == 0); + || strcmp (result, "-infinity 33") == 0); ASSERT (retval == strlen (result)); } @@ -2709,8 +2709,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%Lg %d", NaNl (), 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && strisnan (result, 0, strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } #if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) @@ -2721,8 +2721,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%Lg %d", x.value, 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && strisnan (result, 0, strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } { @@ -2733,8 +2733,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%Lg %d", x.value, 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && strisnan (result, 0, strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } /* The isnanl function should recognize Pseudo-NaNs, Pseudo-Infinities, @@ -2751,8 +2751,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%Lg %d", x.value, 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && strisnan (result, 0, strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } { /* Pseudo-Infinity. */ @@ -2762,8 +2762,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%Lg %d", x.value, 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && strisnan (result, 0, strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } { /* Pseudo-Zero. */ @@ -2773,8 +2773,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%Lg %d", x.value, 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && strisnan (result, 0, strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } { /* Unnormalized number. */ @@ -2784,8 +2784,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%Lg %d", x.value, 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && strisnan (result, 0, strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } { /* Pseudo-Denormal. */ @@ -2795,8 +2795,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%Lg %d", x.value, 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && strisnan (result, 0, strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, 0, strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } #endif @@ -2854,7 +2854,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%#.Lg %d", 9.75L, 33, 44, 55); ASSERT (strcmp (result, "1.e+01 33") == 0 - || strcmp (result, "1.e+001 33") == 0); + || strcmp (result, "1.e+001 33") == 0); ASSERT (retval == strlen (result)); } @@ -2871,7 +2871,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%015Lg %d", -1.0L / 0.0L, 33, 44, 55); ASSERT (strcmp (result, " -inf 33") == 0 - || strcmp (result, " -infinity 33") == 0); + || strcmp (result, " -infinity 33") == 0); ASSERT (retval == strlen (result)); } @@ -2880,8 +2880,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%050Lg %d", NaNl (), 33, 44, 55); ASSERT (strlen (result) == 50 + 3 - && strisnan (result, strspn (result, " "), strlen (result) - 3, 0) - && strcmp (result + strlen (result) - 3, " 33") == 0); + && strisnan (result, strspn (result, " "), strlen (result) - 3, 0) + && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -2890,7 +2890,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) int retval = my_snprintf (result, sizeof (result), "%.Lg %d", 1234.0L, 33, 44, 55); ASSERT (strcmp (result, "1e+03 33") == 0 - || strcmp (result, "1e+003 33") == 0); + || strcmp (result, "1e+003 33") == 0); ASSERT (retval == strlen (result)); } @@ -3075,17 +3075,17 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) for (i = 1; i <= 8; i++) { - char *block; - char result[5000]; - int retval; - - block = (char *) malloc (i); - memcpy (block, "abcdefgh", i); - retval = my_snprintf (result, sizeof (result), "%.*s", (int) i, block); - ASSERT (memcmp (result, block, i) == 0); - ASSERT (result[i] == '\0'); - ASSERT (retval == strlen (result)); - free (block); + char *block; + char result[5000]; + int retval; + + block = (char *) malloc (i); + memcpy (block, "abcdefgh", i); + retval = my_snprintf (result, sizeof (result), "%.*s", (int) i, block); + ASSERT (memcmp (result, block, i) == 0); + ASSERT (result[i] == '\0'); + ASSERT (retval == strlen (result)); + free (block); } } #if HAVE_WCHAR_T @@ -3094,19 +3094,19 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) for (i = 1; i <= 8; i++) { - wchar_t *block; - size_t j; - char result[5000]; - int retval; - - block = (wchar_t *) malloc (i * sizeof (wchar_t)); - for (j = 0; j < i; j++) - block[j] = "abcdefgh"[j]; - retval = my_snprintf (result, sizeof (result), "%.*ls", (int) i, block); - ASSERT (memcmp (result, "abcdefgh", i) == 0); - ASSERT (result[i] == '\0'); - ASSERT (retval == strlen (result)); - free (block); + wchar_t *block; + size_t j; + char result[5000]; + int retval; + + block = (wchar_t *) malloc (i * sizeof (wchar_t)); + for (j = 0; j < i; j++) + block[j] = "abcdefgh"[j]; + retval = my_snprintf (result, sizeof (result), "%.*ls", (int) i, block); + ASSERT (memcmp (result, "abcdefgh", i) == 0); + ASSERT (result[i] == '\0'); + ASSERT (retval == strlen (result)); + free (block); } } #endif |