summaryrefslogtreecommitdiff
path: root/absl
diff options
context:
space:
mode:
authorGravatar Benjamin Barenblat <bbaren@google.com>2024-06-10 10:14:21 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2024-06-10 10:15:20 -0700
commit96cdf6cc87e7a21d92f9f96a72263a93d3929ec7 (patch)
tree89f781ccc08746a8b8b338d9e5f2c1a5f87fb2aa /absl
parent2fc843ef37e3916f30f4c005ce90e3b16db58ea5 (diff)
Disable negative NaN float ostream format checking on RISC-V
It’s not clear whether negative NaN floats are supposed to print as "-nan" or "nan" on RISC-V (https://cplusplus.github.io/LWG/issue4101). Until that’s resolved, don’t require that logging such a float with Abseil produce the same result as streaming it to an ostream does. Closes: https://github.com/abseil/abseil-cpp/issues/1684 PiperOrigin-RevId: 641942176 Change-Id: Iec7ef130cc15c114714f2d124cb37886b3c37ab4
Diffstat (limited to 'absl')
-rw-r--r--absl/log/log_format_test.cc14
1 files changed, 14 insertions, 0 deletions
diff --git a/absl/log/log_format_test.cc b/absl/log/log_format_test.cc
index dbad5d97..8ca6df3e 100644
--- a/absl/log/log_format_test.cc
+++ b/absl/log/log_format_test.cc
@@ -608,6 +608,19 @@ TYPED_TEST(FloatingPointLogFormatTest, NegativeNaN) {
auto comparison_stream = ComparisonStream();
comparison_stream << value;
+ // On RISC-V, don't expect that formatting -NaN produces the same string as
+ // streaming it. #ifdefing out just the relevant line breaks the MSVC build,
+ // so duplicate the entire EXPECT_CALL.
+#ifdef __riscv
+ EXPECT_CALL(
+ test_sink,
+ Send(AllOf(
+ TextMessage(AnyOf(Eq("-nan"), Eq("nan"), Eq("NaN"), Eq("-nan(ind)"))),
+ ENCODED_MESSAGE(
+ AnyOf(EqualsProto(R"pb(value { str: "-nan" })pb"),
+ EqualsProto(R"pb(value { str: "nan" })pb"),
+ EqualsProto(R"pb(value { str: "-nan(ind)" })pb"))))));
+#else
EXPECT_CALL(
test_sink,
Send(AllOf(
@@ -617,6 +630,7 @@ TYPED_TEST(FloatingPointLogFormatTest, NegativeNaN) {
AnyOf(EqualsProto(R"pb(value { str: "-nan" })pb"),
EqualsProto(R"pb(value { str: "nan" })pb"),
EqualsProto(R"pb(value { str: "-nan(ind)" })pb"))))));
+#endif
test_sink.StartCapturingLogs();
LOG(INFO) << value;
}