Skip to content

Commit

Permalink
Support notValue constraints on enums. (#17070)
Browse files Browse the repository at this point in the history
Fixes #16995
  • Loading branch information
bzbarsky-apple authored Apr 6, 2022
1 parent 60adc7e commit 6811e34
Show file tree
Hide file tree
Showing 5 changed files with 822 additions and 635 deletions.
2 changes: 0 additions & 2 deletions src/app/tests/suites/certification/Test_TC_WNCV_2_1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ tests:
error: UNSUPPORTED_WRITE

- label: "3b: reads back the RO mandatory attribute: Type"
disabled: true
command: "readAttribute"
attribute: "Type"
response:
Expand Down Expand Up @@ -130,7 +129,6 @@ tests:
error: UNSUPPORTED_WRITE

- label: "3b: reads back the RO mandatory attribute: EndProductType"
disabled: true
command: "readAttribute"
attribute: "EndProductType"
response:
Expand Down
8 changes: 7 additions & 1 deletion src/app/tests/suites/include/ConstraintsChecker.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ class ConstraintsChecker
return CheckConstraintMaxValue(itemName, current.Value(), static_cast<T>(expected));
}

template <typename T, typename U>
template <typename T, typename U, std::enable_if_t<!std::is_enum<T>::value, int> = 0>
bool CheckConstraintNotValue(const char * itemName, T current, U expected)
{
if (current == expected)
Expand All @@ -257,6 +257,12 @@ class ConstraintsChecker
return true;
}

template <typename T, typename U, std::enable_if_t<std::is_enum<T>::value, int> = 0>
bool CheckConstraintNotValue(const char * itemName, T current, U expected)
{
return CheckConstraintNotValue(itemName, chip::to_underlying(current), expected);
}

template <typename T>
bool CheckConstraintNotValue(const char * itemName, chip::BitFlags<T> current, chip::BitFlags<T> expected)
{
Expand Down
Loading

0 comments on commit 6811e34

Please sign in to comment.