Skip to content

Commit

Permalink
Add support for null in the notValue constraint. (#13107)
Browse files Browse the repository at this point in the history
Now (for a nullable value) you can write:

    notValue: null

in the constraints in yaml and it will do what one expects.
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Feb 5, 2024
1 parent 1385ad8 commit 3a796a7
Show file tree
Hide file tree
Showing 5 changed files with 2,489 additions and 2,620 deletions.
6 changes: 5 additions & 1 deletion examples/chip-tool/templates/partials/test_cluster.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,11 @@ class {{filename}}: public TestCommand
{{~#if expectedConstraints.maxLength}}VerifyOrReturn(CheckConstraintMaxLength("{{>item}}", {{>item}}.size(), {{expectedConstraints.maxLength}}));{{/if}}
{{~#if expectedConstraints.minValue}}VerifyOrReturn(CheckConstraintMinValue<{{chipType}}>("{{>item}}", {{>item}}, {{asTypedLiteral expectedConstraints.minValue type}}));{{/if}}
{{~#if expectedConstraints.maxValue}}VerifyOrReturn(CheckConstraintMaxValue<{{chipType}}>("{{>item}}", {{>item}}, {{asTypedLiteral expectedConstraints.maxValue type}}));{{/if}}
{{~#if expectedConstraints.notValue}}VerifyOrReturn(CheckConstraintNotValue("{{>item}}", {{>item}}, {{asTypedLiteral expectedConstraints.notValue type}}));{{/if}}
{{~#if expectedConstraints.notValue}}
VerifyOrReturn(CheckConstraintNotValue("{{>item}}", {{>item}}, {{asTypedLiteral expectedConstraints.notValue type}}));
{{else if (isLiteralNull expectedConstraints.notValue)}}
VerifyOrReturn(CheckValueNonNull("{{>item}}", {{>item}}));
{{/if}}
{{/if}}

{{#if saveAs}}
Expand Down
7 changes: 7 additions & 0 deletions src/app/tests/suites/TestCluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1783,6 +1783,13 @@ tests:
response:
value: 254

- label: "Read attribute NULLABLE_INT8U unchanged Value with constraint"
command: "readAttribute"
attribute: "nullable_int8u"
response:
constraints:
notValue: null

- label: "Write attribute NULLABLE_INT8U null Value"
command: "writeAttribute"
attribute: "nullable_int8u"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ ResponseHandler {{> subscribeDataCallback}} = nil;
XCTAssertNotEqual([actualValue {{asObjectiveCNumberType "" type true}}Value], {{asTypedLiteral expectedConstraints.notValue type}});
}
}
{{else if (isLiteralNull expectedConstraints.notValue)}}
{
{{> actualValue}}
XCTAssertFalse(actualValue == nil);
}
{{/if}}
{{/if}}
{{/chip_tests_item_response_parameters}}
Expand Down
Loading

0 comments on commit 3a796a7

Please sign in to comment.