Title: [216255] trunk/Tools
Revision
216255
Author
[email protected]
Date
2017-05-05 11:45:16 -0700 (Fri, 05 May 2017)

Log Message

Use EXPECT_EQ() when comparing strings in TestWebKitAPI tests
https://bugs.webkit.org/show_bug.cgi?id=171698

Reviewed by Darin Adler.

We should use EXPECT_EQ() instead of EXPECT_TRUE() to compare WTF::String() objects
so that we get pretty diff output when the actual string differs from the expected
string as opposed to seeing a boolean result. The former makes makes it straightforward
to diagnose a regression without reading the code for the test or instrumenting it to
determine the actual string that was compared.

* TestWebKitAPI/Tests/WTF/WTFString.cpp:
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WebCore/mac/GPUFunction.mm:
(TestWebKitAPI::TEST_F):
* TestWebKitAPI/Tests/WebCore/mac/GPULibrary.mm:
(TestWebKitAPI::TEST_F):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (216254 => 216255)


--- trunk/Tools/ChangeLog	2017-05-05 18:41:36 UTC (rev 216254)
+++ trunk/Tools/ChangeLog	2017-05-05 18:45:16 UTC (rev 216255)
@@ -1,3 +1,23 @@
+2017-05-05  Daniel Bates  <[email protected]>
+
+        Use EXPECT_EQ() when comparing strings in TestWebKitAPI tests
+        https://bugs.webkit.org/show_bug.cgi?id=171698
+
+        Reviewed by Darin Adler.
+
+        We should use EXPECT_EQ() instead of EXPECT_TRUE() to compare WTF::String() objects
+        so that we get pretty diff output when the actual string differs from the expected
+        string as opposed to seeing a boolean result. The former makes makes it straightforward
+        to diagnose a regression without reading the code for the test or instrumenting it to
+        determine the actual string that was compared.
+
+        * TestWebKitAPI/Tests/WTF/WTFString.cpp:
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/Tests/WebCore/mac/GPUFunction.mm:
+        (TestWebKitAPI::TEST_F):
+        * TestWebKitAPI/Tests/WebCore/mac/GPULibrary.mm:
+        (TestWebKitAPI::TEST_F):
+
 2017-05-05  Chris Dumez  <[email protected]>
 
         Rename webProcessDidCrashWithReason callback to webProcessDidTerminate and stop calling webProcessDidCrash for client terminations

Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp (216254 => 216255)


--- trunk/Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp	2017-05-05 18:41:36 UTC (rev 216254)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp	2017-05-05 18:45:16 UTC (rev 216255)
@@ -25,6 +25,7 @@
 
 #include "config.h"
 
+#include "WTFStringUtilities.h"
 #include <limits>
 #include <wtf/MathExtras.h>
 #include <wtf/text/CString.h>
@@ -316,33 +317,33 @@
 TEST(WTF, StringRightBasic)
 {
     auto reference = String::fromUTF8("Cappuccino");
-    EXPECT_TRUE(reference.right(0) == String::fromUTF8(""));
-    EXPECT_TRUE(reference.right(1) == String::fromUTF8("o"));
-    EXPECT_TRUE(reference.right(2) == String::fromUTF8("no"));
-    EXPECT_TRUE(reference.right(3) == String::fromUTF8("ino"));
-    EXPECT_TRUE(reference.right(4) == String::fromUTF8("cino"));
-    EXPECT_TRUE(reference.right(5) == String::fromUTF8("ccino"));
-    EXPECT_TRUE(reference.right(6) == String::fromUTF8("uccino"));
-    EXPECT_TRUE(reference.right(7) == String::fromUTF8("puccino"));
-    EXPECT_TRUE(reference.right(8) == String::fromUTF8("ppuccino"));
-    EXPECT_TRUE(reference.right(9) == String::fromUTF8("appuccino"));
-    EXPECT_TRUE(reference.right(10) == String::fromUTF8("Cappuccino"));
+    EXPECT_EQ(String::fromUTF8(""), reference.right(0));
+    EXPECT_EQ(String::fromUTF8("o"), reference.right(1));
+    EXPECT_EQ(String::fromUTF8("no"), reference.right(2));
+    EXPECT_EQ(String::fromUTF8("ino"), reference.right(3));
+    EXPECT_EQ(String::fromUTF8("cino"), reference.right(4));
+    EXPECT_EQ(String::fromUTF8("ccino"), reference.right(5));
+    EXPECT_EQ(String::fromUTF8("uccino"), reference.right(6));
+    EXPECT_EQ(String::fromUTF8("puccino"), reference.right(7));
+    EXPECT_EQ(String::fromUTF8("ppuccino"), reference.right(8));
+    EXPECT_EQ(String::fromUTF8("appuccino"), reference.right(9));
+    EXPECT_EQ(String::fromUTF8("Cappuccino"), reference.right(10));
 }
 
 TEST(WTF, StringLeftBasic)
 {
     auto reference = String::fromUTF8("Cappuccino");
-    EXPECT_TRUE(reference.left(0) == String::fromUTF8(""));
-    EXPECT_TRUE(reference.left(1) == String::fromUTF8("C"));
-    EXPECT_TRUE(reference.left(2) == String::fromUTF8("Ca"));
-    EXPECT_TRUE(reference.left(3) == String::fromUTF8("Cap"));
-    EXPECT_TRUE(reference.left(4) == String::fromUTF8("Capp"));
-    EXPECT_TRUE(reference.left(5) == String::fromUTF8("Cappu"));
-    EXPECT_TRUE(reference.left(6) == String::fromUTF8("Cappuc"));
-    EXPECT_TRUE(reference.left(7) == String::fromUTF8("Cappucc"));
-    EXPECT_TRUE(reference.left(8) == String::fromUTF8("Cappucci"));
-    EXPECT_TRUE(reference.left(9) == String::fromUTF8("Cappuccin"));
-    EXPECT_TRUE(reference.left(10) == String::fromUTF8("Cappuccino"));
+    EXPECT_EQ(String::fromUTF8(""), reference.left(0));
+    EXPECT_EQ(String::fromUTF8("C"), reference.left(1));
+    EXPECT_EQ(String::fromUTF8("Ca"), reference.left(2));
+    EXPECT_EQ(String::fromUTF8("Cap"), reference.left(3));
+    EXPECT_EQ(String::fromUTF8("Capp"), reference.left(4));
+    EXPECT_EQ(String::fromUTF8("Cappu"), reference.left(5));
+    EXPECT_EQ(String::fromUTF8("Cappuc"), reference.left(6));
+    EXPECT_EQ(String::fromUTF8("Cappucc"), reference.left(7));
+    EXPECT_EQ(String::fromUTF8("Cappucci"), reference.left(8));
+    EXPECT_EQ(String::fromUTF8("Cappuccin"), reference.left(9));
+    EXPECT_EQ(String::fromUTF8("Cappuccino"), reference.left(10));
 }
 
 TEST(WTF, StringReverseFindBasic)

Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/GPUFunction.mm (216254 => 216255)


--- trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/GPUFunction.mm	2017-05-05 18:41:36 UTC (rev 216254)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/GPUFunction.mm	2017-05-05 18:45:16 UTC (rev 216255)
@@ -55,11 +55,11 @@
 
     auto vertexFunction = library->functionWithName("vertex_main");
     EXPECT_NOT_NULL(vertexFunction);
-    EXPECT_TRUE(vertexFunction->name() == "vertex_main");
+    EXPECT_EQ("vertex_main", vertexFunction->name());
 
     auto fragmentFunction = library->functionWithName("fragment_main");
     EXPECT_NOT_NULL(fragmentFunction);
-    EXPECT_TRUE(fragmentFunction->name() == "fragment_main");
+    EXPECT_EQ("fragment_main", fragmentFunction->name());
 
     auto nonExistentFunction = library->functionWithName("name_that_is_not_in_library");
     EXPECT_NULL(nonExistentFunction);

Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/GPULibrary.mm (216254 => 216255)


--- trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/GPULibrary.mm	2017-05-05 18:41:36 UTC (rev 216254)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/GPULibrary.mm	2017-05-05 18:45:16 UTC (rev 216255)
@@ -62,7 +62,7 @@
     EXPECT_NOT_NULL(library);
 
     library->setLabel("TestLabel");
-    EXPECT_TRUE(library->label() == "TestLabel");
+    EXPECT_EQ("TestLabel", library->label());
 }
 
 TEST_F(GPU, LibraryFunctionNames)
@@ -76,8 +76,8 @@
 
     auto functionNames = library->functionNames();
     EXPECT_EQ(functionNames.size(), static_cast<unsigned long>(2));
-    EXPECT_TRUE(functionNames[0] == "vertex_main");
-    EXPECT_TRUE(functionNames[1] == "fragment_main");
+    EXPECT_EQ("vertex_main", functionNames[0]);
+    EXPECT_EQ("fragment_main", functionNames[1]);
 }
 
 } // namespace TestWebKitAPI
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to