summaryrefslogtreecommitdiff
path: root/tests/stdio_test.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2020-06-05 16:56:53 -0700
committerElliott Hughes <enh@google.com>2020-06-11 12:57:37 -0700
commitcdb4a26d29fce473261dceaf4610372fb26d5e64 (patch)
tree804c0c127e949749ada67b410c9acfc65f13e120 /tests/stdio_test.cpp
parent86a8696cfb7813964df988d0f4bf278bf3344a6c (diff)
Update upstream OpenBSD gdtoa.
Also add a test for the bug that this fixes. Bug: http://b/152588929 Test: treehugger Change-Id: I58055b3ebaef457721bb4f5d8a8710025122b2e7
Diffstat (limited to 'tests/stdio_test.cpp')
-rw-r--r--tests/stdio_test.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/stdio_test.cpp b/tests/stdio_test.cpp
index 75abbd235..f6eca05f4 100644
--- a/tests/stdio_test.cpp
+++ b/tests/stdio_test.cpp
@@ -294,6 +294,34 @@ TEST(STDIO_TEST, snprintf_a) {
EXPECT_STREQ("<0x1.3831e147ae148p+13>", buf);
}
+// http://b/152588929
+TEST(STDIO_TEST, snprintf_La) {
+#if defined(__LP64__)
+ char buf[BUFSIZ];
+ union {
+ uint64_t a[2];
+ long double v;
+ } u;
+
+ u.a[0] = UINT64_C(0x9b9b9b9b9b9b9b9b);
+ u.a[1] = UINT64_C(0xdfdfdfdfdfdfdfdf);
+ EXPECT_EQ(41, snprintf(buf, sizeof(buf), "<%La>", u.v));
+ EXPECT_STREQ("<-0x1.dfdfdfdfdfdf9b9b9b9b9b9b9b9bp+8160>", buf);
+
+ u.a[0] = UINT64_C(0xffffffffffffffff);
+ u.a[1] = UINT64_C(0x7ffeffffffffffff);
+ EXPECT_EQ(41, snprintf(buf, sizeof(buf), "<%La>", u.v));
+ EXPECT_STREQ("<0x1.ffffffffffffffffffffffffffffp+16383>", buf);
+
+ u.a[0] = UINT64_C(0x0000000000000000);
+ u.a[1] = UINT64_C(0x0000000000000000);
+ EXPECT_EQ(8, snprintf(buf, sizeof(buf), "<%La>", u.v));
+ EXPECT_STREQ("<0x0p+0>", buf);
+#else
+ GTEST_SKIP() << "no ld128";
+#endif
+}
+
TEST(STDIO_TEST, snprintf_lc) {
char buf[BUFSIZ];
wint_t wc = L'a';