Bug 171698 - Use EXPECT_EQ() when comparing strings in TestWebKitAPI tests
Summary: Use EXPECT_EQ() when comparing strings in TestWebKitAPI tests
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Daniel Bates
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-05-04 15:46 PDT by Daniel Bates
Modified: 2017-05-05 11:45 PDT (History)
4 users (show)

See Also:


Attachments
Patch (6.68 KB, patch)
2017-05-04 15:58 PDT, Daniel Bates
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Bates 2017-05-04 15:46:42 PDT
We should use EXPECT_EQ() when comparing WTF::String objects so that we get pretty-printed difference output for both the expected result and actual results. This can help expedite the diagnosis of a regression.

== Current Behavior ==

Suppose we change line <http://trac.webkit.org/browser/trunk/Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp?rev=216131#L337> to purposely cause an failure:

EXPECT_TRUE(reference.left(1) == String::fromUTF8("Ca"));

Then run-api-tests will emit the following output:

Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp:337
Value of: reference.left(1) == String::fromUTF8("Ca")
  Actual: false
Expected: true

== Proposed Behavior ==

Suppose we change the same line to purposely failure and use EXPECT_EQ():

EXPECT_EQ(String::fromUTF8("Ca"), reference.left(1));

Then run-api-tests will emit the following output:

Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp:337
Value of: reference.left(1)
  Actual: C
Expected: String::fromUTF8("Ca")
Which is: Ca
Comment 1 Daniel Bates 2017-05-04 15:48:00 PDT
(In reply to Daniel Bates from comment #0)
> Suppose we change line
> <http://trac.webkit.org/browser/trunk/Tools/TestWebKitAPI/Tests/WTF/
> WTFString.cpp?rev=216131#L337> to purposely cause an failure:

The line should be <http://trac.webkit.org/browser/trunk/Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp?rev=216131#L336>
Comment 2 Daniel Bates 2017-05-04 15:58:45 PDT
Created attachment 309111 [details]
Patch
Comment 3 Daniel Bates 2017-05-05 11:45:24 PDT
Committed r216255: <http://trac.webkit.org/changeset/216255>