commit 44de8b2a53f2e42ef505e7e5b2c5d949509e0f08
parent b47bfeb836972a0c4654a68f2bf6ad2f487ed82c
Author: Edgar Chen <echen@mozilla.com>
Date: Thu, 16 Oct 2025 07:23:05 +0000
Bug 1992067 - Use ASSERT_EQ() in PlainTextSerializer gtests; r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D267909
Diffstat:
1 file changed, 39 insertions(+), 25 deletions(-)
diff --git a/dom/serializers/gtest/TestPlainTextSerializer.cpp b/dom/serializers/gtest/TestPlainTextSerializer.cpp
@@ -39,8 +39,8 @@ TEST(PlainTextSerializer, ASCIIWithFlowedDelSp)
"Firefox Firefox Firefox Firefox "
"Firefox \r\nFirefox Firefox Firefox\r\n");
- ASSERT_TRUE(test.Equals(result))
- << "Wrong HTML to ASCII text serialization with format=flowed; delsp=yes";
+ ASSERT_EQ(test, result)
+ << "Wrong HTML to ASCII text serialization with format=flowed; delsp=yes";
}
TEST(PlainTextSerializer, Bug1864820)
@@ -70,8 +70,7 @@ TEST(PlainTextSerializer, Bug1864820)
)#");
result.Trim(" \n");
test.Trim(" \n");
- ASSERT_TRUE(test.Equals(result))
- << "Shouldn't hang with format=flowed: " << NS_ConvertUTF16toUTF8(test).get();
+ ASSERT_EQ(test, result) << "Shouldn't hang with format=flowed";
}
// Test for CJK with format=flowed; delsp=yes
@@ -105,8 +104,8 @@ TEST(PlainTextSerializer, CJKWithFlowedDelSp)
}
result.AppendLiteral("\r\n");
- ASSERT_TRUE(test.Equals(result))
- << "Wrong HTML to CJK text serialization with format=flowed; delsp=yes";
+ ASSERT_EQ(test, result)
+ << "Wrong HTML to CJK text serialization with format=flowed; delsp=yes";
}
// Test for CJK with DisallowLineBreaking
@@ -136,8 +135,8 @@ TEST(PlainTextSerializer, CJKWithDisallowLineBreaking)
}
result.AppendLiteral("\r\n");
- ASSERT_TRUE(test.Equals(result))
- << "Wrong HTML to CJK text serialization with OutputDisallowLineBreaking";
+ ASSERT_EQ(test, result)
+ << "Wrong HTML to CJK text serialization with OutputDisallowLineBreaking";
}
// Test for Latin with DisallowLineBreaking
@@ -166,8 +165,8 @@ TEST(PlainTextSerializer, LatinWithDisallowLineBreaking)
}
expect.AppendLiteral(" \r\n\r\n");
- ASSERT_TRUE(test.Equals(expect))
- << "Wrong HTML to Latin text serialization with OutputDisallowLineBreaking";
+ ASSERT_EQ(test, expect) << "Wrong HTML to Latin text serialization with "
+ "OutputDisallowLineBreaking";
}
// Test for ASCII with format=flowed; and quoted lines in preformatted span.
@@ -250,8 +249,11 @@ TEST(PlainTextSerializer, PrettyPrintedHtml)
"</body>" NS_LINEBREAK "</html>");
ConvertBufToPlainText(test, 0, kDefaultWrapColumn);
- ASSERT_TRUE(test.EqualsLiteral("first" NS_LINEBREAK "second" NS_LINEBREAK))
- << "Wrong prettyprinted html to text serialization";
+
+ nsAutoString expect;
+ expect.AppendLiteral("first" NS_LINEBREAK "second" NS_LINEBREAK);
+
+ ASSERT_EQ(test, expect) << "Wrong prettyprinted html to text serialization";
}
TEST(PlainTextSerializer, PreElement)
@@ -263,9 +265,12 @@ TEST(PlainTextSerializer, PreElement)
"</body>" NS_LINEBREAK "</html>");
ConvertBufToPlainText(test, 0, kDefaultWrapColumn);
- ASSERT_TRUE(test.EqualsLiteral(" first" NS_LINEBREAK
- " second" NS_LINEBREAK NS_LINEBREAK))
- << "Wrong prettyprinted html to text serialization";
+
+ nsAutoString expect;
+ expect.AppendLiteral(" first" NS_LINEBREAK
+ " second" NS_LINEBREAK NS_LINEBREAK);
+
+ ASSERT_EQ(test, expect) << "Wrong prettyprinted html to text serialization";
}
TEST(PlainTextSerializer, BlockElement)
@@ -278,8 +283,11 @@ TEST(PlainTextSerializer, BlockElement)
"</body>" NS_LINEBREAK "</html>");
ConvertBufToPlainText(test, 0, kDefaultWrapColumn);
- ASSERT_TRUE(test.EqualsLiteral("first" NS_LINEBREAK "second" NS_LINEBREAK))
- << "Wrong prettyprinted html to text serialization";
+
+ nsAutoString expect;
+ expect.AppendLiteral("first" NS_LINEBREAK "second" NS_LINEBREAK);
+
+ ASSERT_EQ(test, expect) << "Wrong prettyprinted html to text serialization";
}
TEST(PlainTextSerializer, PreWrapElementForThunderbird)
@@ -295,13 +303,16 @@ TEST(PlainTextSerializer, PreWrapElementForThunderbird)
const uint32_t wrapColumn = 10;
ConvertBufToPlainText(test, nsIDocumentEncoder::OutputWrap, wrapColumn);
+
// "\n\n first\nline is\ntoo long\n second\nline is\neven\nloooonger\n\n\n"
- ASSERT_TRUE(test.EqualsLiteral(
- NS_LINEBREAK NS_LINEBREAK
- " first" NS_LINEBREAK "line is" NS_LINEBREAK "too long" NS_LINEBREAK
- " second" NS_LINEBREAK "line is" NS_LINEBREAK "even" NS_LINEBREAK
- "loooonger" NS_LINEBREAK NS_LINEBREAK NS_LINEBREAK))
- << "Wrong prettyprinted html to text serialization";
+ nsAutoString expect;
+ expect.AppendLiteral(NS_LINEBREAK NS_LINEBREAK
+ " first" NS_LINEBREAK "line is" NS_LINEBREAK
+ "too long" NS_LINEBREAK " second" NS_LINEBREAK
+ "line is" NS_LINEBREAK "even" NS_LINEBREAK
+ "loooonger" NS_LINEBREAK NS_LINEBREAK NS_LINEBREAK);
+
+ ASSERT_EQ(test, expect) << "Wrong prettyprinted html to text serialization";
}
TEST(PlainTextSerializer, Simple)
@@ -311,8 +322,11 @@ TEST(PlainTextSerializer, Simple)
"<html><base>base</base><head><span>span</span></head>"
"<body>body</body></html>");
ConvertBufToPlainText(test, 0, kDefaultWrapColumn);
- ASSERT_TRUE(test.EqualsLiteral("basespanbody"))
- << "Wrong html to text serialization";
+
+ nsAutoString expect;
+ expect.AppendLiteral("basespanbody");
+
+ ASSERT_EQ(test, expect) << "Wrong html to text serialization";
}
TEST(PlainTextSerializer, OneHundredAndOneOL)