Skip to content

Commit

Permalink
[Impeller] Add EXPECT_OBJ_NEAR macros similar to the ASSERT_OBJ_NEAR …
Browse files Browse the repository at this point in the history
…versions (flutter#47795)

Fixes flutter/flutter#137873

The `ASSERT_..._NEAR` macros are used in many places in the Impeller unit tests, but they are "fatal errors" in that they immediately exit the individual unit test. These versions allow testing expectations without ending the unit test early.
  • Loading branch information
flar authored Nov 8, 2023
1 parent b0310da commit 0ac3c65
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 12 additions & 0 deletions impeller/geometry/geometry_asserts.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,15 @@ inline ::testing::AssertionResult ColorsNear(std::vector<impeller::Color> a,
#define ASSERT_ARRAY_4_NEAR(a, b) ASSERT_PRED2(&::Array4Near, a, b)
#define ASSERT_COLOR_BUFFER_NEAR(a, b) ASSERT_PRED2(&::ColorBufferNear, a, b)
#define ASSERT_COLORS_NEAR(a, b) ASSERT_PRED2(&::ColorsNear, a, b)

#define EXPECT_MATRIX_NEAR(a, b) EXPECT_PRED2(&::MatrixNear, a, b)
#define EXPECT_QUATERNION_NEAR(a, b) EXPECT_PRED2(&::QuaternionNear, a, b)
#define EXPECT_RECT_NEAR(a, b) EXPECT_PRED2(&::RectNear, a, b)
#define EXPECT_COLOR_NEAR(a, b) EXPECT_PRED2(&::ColorNear, a, b)
#define EXPECT_POINT_NEAR(a, b) EXPECT_PRED2(&::PointNear, a, b)
#define EXPECT_VECTOR3_NEAR(a, b) EXPECT_PRED2(&::Vector3Near, a, b)
#define EXPECT_VECTOR4_NEAR(a, b) EXPECT_PRED2(&::Vector4Near, a, b)
#define EXPECT_SIZE_NEAR(a, b) EXPECT_PRED2(&::SizeNear, a, b)
#define EXPECT_ARRAY_4_NEAR(a, b) EXPECT_PRED2(&::Array4Near, a, b)
#define EXPECT_COLOR_BUFFER_NEAR(a, b) EXPECT_PRED2(&::ColorBufferNear, a, b)
#define EXPECT_COLORS_NEAR(a, b) EXPECT_PRED2(&::ColorsNear, a, b)
4 changes: 2 additions & 2 deletions impeller/geometry/rect_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ TEST(RectTest, RectMakeSize) {
Size s(100, 200);
Rect r = Rect::MakeSize(s);
Rect expected = Rect::MakeLTRB(0, 0, 100, 200);
ASSERT_RECT_NEAR(r, expected);
EXPECT_RECT_NEAR(r, expected);
}

{
ISize s(100, 200);
Rect r = Rect::MakeSize(s);
Rect expected = Rect::MakeLTRB(0, 0, 100, 200);
ASSERT_RECT_NEAR(r, expected);
EXPECT_RECT_NEAR(r, expected);
}

{
Expand Down

0 comments on commit 0ac3c65

Please sign in to comment.