From bb1eb7554a01d005e36a4a93b1e87068893aafdd Mon Sep 17 00:00:00 2001 From: Chi Tsai Date: Mon, 9 Dec 2024 20:05:26 -0800 Subject: [PATCH] Fix SynthTraceSerializationTest for Windows (#1577) Summary: Pull Request resolved: https://github.com/facebook/hermes/pull/1577 MSVC has stringizing bug where it doesn't process code units in raw string literals. See example: https://godbolt.org/z/osjYj95rq Temporary fix is to move the string literal out of the `EXPECT_EQ` macro until this gets fixed. Reviewed By: neildhar Differential Revision: D66914807 fbshipit-source-id: 947d4f2254d23ee322dcc063b40f8d05575987d1 --- unittests/API/SynthTraceSerializationTest.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/unittests/API/SynthTraceSerializationTest.cpp b/unittests/API/SynthTraceSerializationTest.cpp index cece29a54b9..1b17f84af3c 100644 --- a/unittests/API/SynthTraceSerializationTest.cpp +++ b/unittests/API/SynthTraceSerializationTest.cpp @@ -396,23 +396,31 @@ TEST_F(SynthTraceSerializationTest, Utf8Record) { } TEST_F(SynthTraceSerializationTest, Utf16Record) { + auto serialized = + R"({"type":"Utf16Record","time":0,"objID":"string:123","retval":"hi\ud83d\udc4b"})"; EXPECT_EQ( - R"({"type":"Utf16Record","time":0,"objID":"string:123","retval":"hi\ud83d\udc4b"})", + serialized, to_string(SynthTrace::Utf16Record( dummyTime, SynthTrace::encodeString(123), u"hiđź‘‹"))); + serialized = + R"({"type":"Utf16Record","time":0,"objID":"string:111","retval":"\ud83d"})"; EXPECT_EQ( - R"({"type":"Utf16Record","time":0,"objID":"string:111","retval":"\ud83d"})", + serialized, to_string(SynthTrace::Utf16Record( dummyTime, SynthTrace::encodeString(111), u"\xd83d"))); } TEST_F(SynthTraceSerializationTest, GetStringDataRecord) { + auto serialized = + R"({"type":"GetStringDataRecord","time":0,"objID":"string:123","strData":"\nhello\ud83d\udc4b\\"})"; EXPECT_EQ( - R"({"type":"GetStringDataRecord","time":0,"objID":"string:123","strData":"\nhello\ud83d\udc4b\\"})", + serialized, to_string(SynthTrace::GetStringDataRecord( dummyTime, SynthTrace::encodeString(123), u"\nhellođź‘‹\\"))); + serialized = + R"({"type":"GetStringDataRecord","time":0,"objID":"propNameID:111","strData":"\ud83d"})"; EXPECT_EQ( - R"({"type":"GetStringDataRecord","time":0,"objID":"propNameID:111","strData":"\ud83d"})", + serialized, to_string(SynthTrace::GetStringDataRecord( dummyTime, SynthTrace::encodePropNameID(111), u"\xd83d"))); }