tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 7f8cb6c34c8dcc40672258b59319e80eae916e0a
parent e2fbc47166f364668a5bd613e267b50de6081764
Author: Edgar Chen <echen@mozilla.com>
Date:   Tue, 14 Oct 2025 07:44:07 +0000

Bug 1992067 - Use ASSERT_EQ() in PlainTextSerializer gtests; r=masayuki

Differential Revision: https://phabricator.services.mozilla.com/D267909

Diffstat:
Mdom/serializers/gtest/TestPlainTextSerializer.cpp | 64+++++++++++++++++++++++++++++++++++++++-------------------------
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)