diff options
-rw-r--r-- | include/libcamera/geometry.h | 1 | ||||
-rw-r--r-- | src/libcamera/geometry.cpp | 6 | ||||
-rw-r--r-- | test/geometry.cpp | 10 |
3 files changed, 17 insertions, 0 deletions
diff --git a/include/libcamera/geometry.h b/include/libcamera/geometry.h index edda42cf..7d4b8bcf 100644 --- a/include/libcamera/geometry.h +++ b/include/libcamera/geometry.h @@ -41,6 +41,7 @@ struct Size { unsigned int width; unsigned int height; + bool isNull() const { return !width && !height; } const std::string toString() const; }; diff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp index fd78cf2c..24c44fb4 100644 --- a/src/libcamera/geometry.cpp +++ b/src/libcamera/geometry.cpp @@ -108,6 +108,12 @@ bool operator==(const Rectangle &lhs, const Rectangle &rhs) */ /** + * \fn bool Size::isNull() const + * \brief Check if the size is null + * \return True if both the width and height are 0, or false otherwise + */ + +/** * \brief Assemble and return a string describing the size * \return A string describing the size */ diff --git a/test/geometry.cpp b/test/geometry.cpp index 27e65565..904ad92c 100644 --- a/test/geometry.cpp +++ b/test/geometry.cpp @@ -36,6 +36,16 @@ protected: int run() { + if (!Size().isNull() || !Size(0, 0).isNull()) { + cout << "Null size incorrectly reported as not null" << endl; + return TestFail; + } + + if (Size(0, 100).isNull() || Size(100, 0).isNull() || Size(100, 100).isNull()) { + cout << "Non-null size incorrectly reported as null" << endl; + return TestFail; + } + /* Test Size equality and inequality. */ if (!compare(Size(100, 100), Size(100, 100), &operator==, "==", true)) return TestFail; |