Skip to content

Commit

Permalink
Added a CheckConstraint Min and Max function where the expected is a …
Browse files Browse the repository at this point in the history
…Nullable type (#27045)

* Added a CheckConstraint Min and Max function where the expected is a Nullable type

* Reversed the null check as it was wrong way around. Fixed new parameter to reference and const

* Fixed return parameters

Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>

* Fixed return parameters

Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>

* Removed enable_if_t from new template functions

---------

Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>
  • Loading branch information
2 people authored and pull[bot] committed Nov 29, 2023
1 parent be3d09a commit 174ca71
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/app/tests/suites/include/ConstraintsChecker.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,17 @@ class ConstraintsChecker
return CheckConstraintMinValue(itemName, current.Value(), static_cast<T>(expected));
}

template <typename T, typename U>
bool CheckConstraintMinValue(const char * itemName, const chip::app::DataModel::Nullable<T> & current,
const chip::app::DataModel::Nullable<U> & expected)
{
if (expected.IsNull())
{
return true;
}
return CheckConstraintMinValue(itemName, current, expected.Value());
}

template <typename T, typename U>
bool CheckConstraintMinValue(const char * itemName, const T & current, const chip::Optional<U> & expected)
{
Expand Down Expand Up @@ -375,6 +386,17 @@ class ConstraintsChecker
return CheckConstraintMaxValue(itemName, current.Value(), static_cast<T>(expected));
}

template <typename T, typename U>
bool CheckConstraintMaxValue(const char * itemName, const chip::app::DataModel::Nullable<T> & current,
const chip::app::DataModel::Nullable<U> & expected)
{
if (expected.IsNull())
{
return true;
}
return CheckConstraintMaxValue(itemName, current, expected.Value());
}

template <typename T, typename U>
bool CheckConstraintMaxValue(const char * itemName, const T & current, const chip::Optional<U> & expected)
{
Expand Down

0 comments on commit 174ca71

Please sign in to comment.