From dd0793ed1b28a6819116d6bfa676bc3d1a028780 Mon Sep 17 00:00:00 2001 From: Jacopo Mondi Date: Wed, 1 Jul 2020 10:21:17 +0200 Subject: libcamera: geometry: Add isNull() function to Rectangle class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's common for code to check if a rectangle is null. Add a helper function to do so and test the function in test/geometry.cpp Reviewed-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Signed-off-by: Jacopo Mondi --- test/geometry.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test') diff --git a/test/geometry.cpp b/test/geometry.cpp index 1a9fc1b8..08e268c9 100644 --- a/test/geometry.cpp +++ b/test/geometry.cpp @@ -182,6 +182,20 @@ protected: if (!compare(Size(200, 100), Size(100, 200), &operator>=, ">=", true)) return TestFail; + /* Test Rectangle::isNull(). */ + if (!Rectangle(0, 0, 0, 0).isNull() || + !Rectangle(1, 1, 0, 0).isNull()) { + cout << "Null rectangle incorrectly reported as not null" << endl; + return TestFail; + } + + if (Rectangle(0, 0, 0, 1).isNull() || + Rectangle(0, 0, 1, 0).isNull() || + Rectangle(0, 0, 1, 1).isNull()) { + cout << "Non-null rectangle incorrectly reported as null" << endl; + return TestFail; + } + return TestPass; } }; -- cgit v1.2.1