Skip to content

Commit

Permalink
Support empty lists in yaml tests. (#11496)
Browse files Browse the repository at this point in the history
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Jan 11, 2022
1 parent a70ee51 commit 3556773
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 41 deletions.
2 changes: 1 addition & 1 deletion examples/chip-tool/templates/partials/test_cluster.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class {{filename}}: public TestCommand
{{/if}}
VerifyOrReturn(CheckValue
{{~#if isList}}AsListLength("{{>itemValue}}", {{>itemValue}}, {{expectedValue.length}})
{{else if isArray}}AsList("{{>itemValue}}", {{>itemValue}}, {{expectedValue}})
{{else if isArray}}AsList("{{>itemValue}}", {{>itemValue}}{{#if expectedValue.length}}, {{expectedValue}}{{/if}})
{{else if (isString type)}}AsString("{{>itemValue}}", {{>itemValue}}, "{{expectedValue}}")
{{else}}<{{chipType}}>("{{>itemValue}}", {{>itemValue}}, {{expectedValue}}{{asTypeLiteralSuffix type}})
{{/if}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@
{{! forceNotList=true because we really want the type of a single item here.
Similarly, forceNotOptional=true and forceNotNullable=true because we
have accounted for those already. }}
{{#if definedValue.length}}
{{zapTypeToEncodableClusterObjectType type ns=ns forceNotList=true forceNotNullable=true forceNotOptional=true}} {{asLowerCamelCase label}}List[{{definedValue.length}}];
{{#each definedValue}}
{{>commandValue ns=../ns container=(concat (asLowerCamelCase ../label) "List[" @index "]") definedValue=. type=../type ignore=true}}
{{/each}}
{{container}}{{#unless ignore}}.{{asLowerCamelCase label}}{{/unless}} = {{asLowerCamelCase label}}List;

{{else}}
{{container}}{{#unless ignore}}.{{asLowerCamelCase label}}{{/unless}} = chip::app::DataModel::List<{{zapTypeToEncodableClusterObjectType type ns=ns forceNotList=true forceNotNullable=true forceNotOptional=true}}>();
{{/if}}
{{else}}
{{#if_is_struct type}}

Expand Down
12 changes: 12 additions & 0 deletions src/app/tests/suites/TestClusterComplexTypes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,18 @@ tests:
- name: "arg1"
value: [9, 8, 7, 6, 5, 4, 3, 2, 1]

- label:
"Send Test Command With empty List of INT8U and get an empty list back"
command: "testListInt8UReverseRequest"
arguments:
values:
- name: "arg1"
value: []
response:
values:
- name: "arg1"
value: []

- label:
"Send Test Command With List of Struct Argument and arg1.b of first
item is true"
Expand Down
113 changes: 74 additions & 39 deletions zzz_generated/chip-tool/zap-generated/test/Commands.h

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

0 comments on commit 3556773

Please sign in to comment.