blob: 363e2b86dd79e09012ea13d4bd93d72b33bb7853 [file] [log] [blame]
{{#if isOptional}}
{{! This just means we expect a non-nil value. Go ahead and check the value,
stripping the optionality off. }}
{{>check_test_value actual=actual expected=expected cluster=cluster isOptional=false}}
{{else if isNullable}}
{{#if (isLiteralNull expected)}}
VerifyOrReturn(CheckValueNull("{{label}}", {{actual}}));
{{else}}
{{#if (chip_tests_variables_has expected)}}
{{! Expected value is also a nullable. }}
if ({{expected}} == nil) {
VerifyOrReturn(CheckValueNull("{{label}}", {{actual}}));
} else {
{{/if}}
VerifyOrReturn(CheckValueNonNull("{{label}}", {{actual}}));
{{>check_test_value actual=actual expected=expected cluster=cluster isNullable=false}}
{{#if (chip_tests_variables_has expected)}}
}
{{/if}}
{{/if}}
{{else if isArray}}
VerifyOrReturn(CheckValue("{{label}}", [{{actual}} count], static_cast<uint32_t>({{expected.length}})));
{{#each expected}}
{{>check_test_value actual=(concat ../actual "[" @index "]") expected=this cluster=../cluster isArray=false type=../type parent=../parent}}
{{/each}}
{{else}}
{{#if_is_struct type}}
{{! Iterate over the actual types in the struct, so we pick up the right
type/optionality/nullability information for them for our recursive
call. }}
{{#zcl_struct_items_by_struct_name type}}
{{#if (hasProperty ../expected label)}}
{{>check_test_value actual=(concat "((MTR" (asUpperCamelCase ../cluster) "Cluster" (asUpperCamelCase ../type) " *)" ../actual ")." (asStructPropertyName label)) expected=(lookup ../expected label) cluster=../cluster}}
{{/if}}
{{/zcl_struct_items_by_struct_name}}
{{! Maybe we should add a check for properties in the expected object (other
than "global") that are not present in the struct ? }}
{{else}}
VerifyOrReturn(CheckValue{{#if (isString type)}}AsString{{/if}}("{{label}}", {{actual}},
{{~#if (chip_tests_variables_has expected)}}{{expected}}
{{~else if (isOctetString type)}}
{{> octetStringValue value=expected}}
{{~else if (isCharString type)}}@"{{expected}}"
{{else if (chip_tests_config_has expected)}}m{{asUpperCamelCase expected}}.HasValue() ? m{{asUpperCamelCase expected}}.Value() : {{asTypedLiteral (chip_tests_config_get_default_value expected) (chip_tests_config_get_type expected)}}
{{~else}}{{asTypedExpressionFromObjectiveC expected type}}
{{~/if}}));
{{/if_is_struct}}
{{/if}}