Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(329)

Unified Diff: third_party/WebKit/Source/platform/geometry/FloatRectTest.cpp

Issue 2191233002: Add platform/geometry pretty printers for logging and testing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adjust tests to work around uninteresting cross-platform differences Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/geometry/FloatRectTest.cpp
diff --git a/third_party/WebKit/Source/platform/geometry/FloatRectTest.cpp b/third_party/WebKit/Source/platform/geometry/FloatRectTest.cpp
index 4df2462336a72450600fd317545b25505c0c3b61..74c72ccb18a09d1e8b0fa903a28e5f3c08f00cb7 100644
--- a/third_party/WebKit/Source/platform/geometry/FloatRectTest.cpp
+++ b/third_party/WebKit/Source/platform/geometry/FloatRectTest.cpp
@@ -7,7 +7,6 @@
#include "platform/geometry/FloatPoint.h"
#include "platform/geometry/GeometryTestHelpers.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "wtf/text/WTFString.h"
namespace blink {
@@ -112,18 +111,37 @@ TEST(FloatRectTest, SquaredDistanceToTest)
EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, r1.squaredDistanceTo(p24), 50000.f);
}
-#ifndef NDEBUG
-TEST(FloatRectTest, ToString)
+TEST(FloatRectTest, Formatting)
{
FloatRect emptyRect = FloatRect();
- EXPECT_EQ(String("0.000000,0.000000 0.000000x0.000000"), emptyRect.toString());
+ std::ostringstream emptyRectStream;
+ emptyRectStream << emptyRect;
+ EXPECT_EQ("FloatRect(x=0, y=0, width=0, height=0)", emptyRectStream.str());
FloatRect rect(1, 2, 3, 4);
- EXPECT_EQ(String("1.000000,2.000000 3.000000x4.000000"), rect.toString());
+ std::ostringstream rectStream;
+ rectStream << rect;
+ EXPECT_EQ("FloatRect(x=1, y=2, width=3, height=4)", rectStream.str());
FloatRect granularRect(1.6f, 2.7f, 3.8f, 4.9f);
- EXPECT_EQ(String("1.600000,2.700000 3.800000x4.900000"), granularRect.toString());
+ std::ostringstream granularRectStream;
+ granularRectStream << granularRect;
+ EXPECT_EQ("FloatRect(x=1.6, y=2.7, width=3.8, height=4.9)", granularRectStream.str());
+
+ FloatRect minMaxRect(std::numeric_limits<float>::min(), std::numeric_limits<float>::max(), std::numeric_limits<float>::min(), std::numeric_limits<float>::max());
+ std::ostringstream minMaxRectStream;
+ minMaxRectStream << minMaxRect;
+ EXPECT_EQ("FloatRect(x=1.17549e-38, y=3.40282e+38, width=1.17549e-38, height=3.40282e+38)", minMaxRectStream.str());
+
+ FloatRect infiniteRect(-std::numeric_limits<float>::infinity(), -std::numeric_limits<float>::infinity(), std::numeric_limits<float>::infinity(), std::numeric_limits<float>::infinity());
+ std::ostringstream infiniteRectStream;
+ infiniteRectStream << infiniteRect;
+ EXPECT_EQ("FloatRect(x=-inf, y=-inf, width=inf, height=inf)", infiniteRectStream.str());
+
+ FloatRect nanRect(0, 0, std::numeric_limits<float>::signaling_NaN(), std::numeric_limits<float>::signaling_NaN());
+ std::ostringstream nanRectStream;
+ nanRectStream << nanRect;
+ EXPECT_EQ("FloatRect(x=0, y=0, width=nan, height=nan)", nanRectStream.str());
}
-#endif
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698