Skip to content

Commit

Permalink
[YAML - Darwin] Generate saveAs code not only when the 'value' keywor…
Browse files Browse the repository at this point in the history
…d is used (#14322)
  • Loading branch information
vivien-apple authored Jan 26, 2022
1 parent 2802ba5 commit d123146
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 11 deletions.
21 changes: 12 additions & 9 deletions src/darwin/Framework/CHIP/templates/partials/test_cluster.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,6 @@ ResponseHandler {{> subscribeDataCallback}} = nil;
{
{{> actualValue}}
{{>check_test_value actual="actualValue" expected=expectedValue cluster=../cluster}}
{{#if saveAs}}
{{#if (isOctetString type)}}
{{saveAs}} = [NSMutableData dataWithData:actualValue];
{{else if (isCharString type)}}
{{saveAs}} = [NSMutableString stringWithString:actualValue];
{{else}}
{{saveAs}} = [actualValue {{asObjectiveCNumberType "" type true}}Value];
{{/if}}
{{/if}}
}
{{/if}}
{{#if hasExpectedConstraints}}
Expand Down Expand Up @@ -193,6 +184,18 @@ ResponseHandler {{> subscribeDataCallback}} = nil;
}
{{/if}}
{{/if}}
{{#if saveAs}}
{
{{> actualValue}}
{{#if (isOctetString type)}}
{{saveAs}} = [NSMutableData dataWithData:actualValue];
{{else if (isCharString type)}}
{{saveAs}} = [NSMutableString stringWithString:actualValue];
{{else}}
{{saveAs}} = [actualValue {{asObjectiveCNumberType "" type true}}Value];
{{/if}}
}
{{/if}}
{{/chip_tests_item_response_parameters}}

{{#unless async}}
Expand Down
78 changes: 76 additions & 2 deletions src/darwin/Framework/CHIPTests/CHIPClustersTests.m

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d123146

Please sign in to comment.