diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/fxcrt/fx_coordinates.cpp | 8 | ||||
-rw-r--r-- | core/fxcrt/fx_coordinates.h | 4 | ||||
-rw-r--r-- | core/fxcrt/fx_coordinates_unittest.cpp | 19 |
3 files changed, 31 insertions, 0 deletions
diff --git a/core/fxcrt/fx_coordinates.cpp b/core/fxcrt/fx_coordinates.cpp index db4bea945f..ac13a32329 100644 --- a/core/fxcrt/fx_coordinates.cpp +++ b/core/fxcrt/fx_coordinates.cpp @@ -199,6 +199,14 @@ FX_RECT CFX_FloatRect::ToRoundedFxRect() const { FXSYS_round(bottom)); } +#ifndef NDEBUG +std::ostream& operator<<(std::ostream& os, const CFX_FloatRect& rect) { + os << "rect[" << rect.Width() << "x" << rect.Height() << " (" << rect.left + << ", " << rect.bottom << ")]"; + return os; +} +#endif + CFX_Matrix CFX_Matrix::GetInverse() const { CFX_Matrix inverse; float i = a * d - b * c; diff --git a/core/fxcrt/fx_coordinates.h b/core/fxcrt/fx_coordinates.h index c53d157610..69d16d1c55 100644 --- a/core/fxcrt/fx_coordinates.h +++ b/core/fxcrt/fx_coordinates.h @@ -357,6 +357,10 @@ class CFX_FloatRect { float top; }; +#ifndef NDEBUG +std::ostream& operator<<(std::ostream& os, const CFX_FloatRect& rect); +#endif + // LTWH rectangles (y-axis runs downwards). template <class BaseType> class CFX_RTemplate { diff --git a/core/fxcrt/fx_coordinates_unittest.cpp b/core/fxcrt/fx_coordinates_unittest.cpp index 5be3aa83f9..3368a40e18 100644 --- a/core/fxcrt/fx_coordinates_unittest.cpp +++ b/core/fxcrt/fx_coordinates_unittest.cpp @@ -192,6 +192,25 @@ TEST(CFX_FloatRect, ScaleFromCenterPointEmpty) { EXPECT_FLOAT_EQ(0.0f, rect.top); } +#ifndef NDEBUG +TEST(CFX_FloatRect, Print) { + std::ostringstream os; + CFX_FloatRect rect; + os << rect; + EXPECT_STREQ("rect[0x0 (0, 0)]", os.str().c_str()); + + os.str(""); + rect = CFX_FloatRect(10, 20, 14, 23); + os << rect; + EXPECT_STREQ("rect[4x3 (10, 20)]", os.str().c_str()); + + os.str(""); + rect = CFX_FloatRect(10.5, 20.5, 14.75, 23.75); + os << rect; + EXPECT_STREQ("rect[4.25x3.25 (10.5, 20.5)]", os.str().c_str()); +} +#endif + TEST(CFX_Matrix, ReverseIdentity) { CFX_Matrix m; m.SetIdentity(); |