libcamera: geometry: Add isNull() function to Size class
It's common for code to check if a size is null. Add a helper function to do so. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Umang Jain <email@uajain.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
This commit is contained in:
parent
d8848693bf
commit
7fc65e9680
3 changed files with 17 additions and 0 deletions
|
@ -41,6 +41,7 @@ struct Size {
|
|||
unsigned int width;
|
||||
unsigned int height;
|
||||
|
||||
bool isNull() const { return !width && !height; }
|
||||
const std::string toString() const;
|
||||
};
|
||||
|
||||
|
|
|
@ -107,6 +107,12 @@ bool operator==(const Rectangle &lhs, const Rectangle &rhs)
|
|||
* \brief The Size height
|
||||
*/
|
||||
|
||||
/**
|
||||
* \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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue