asserts.fields
Check the exact set of structure fields.
📝Syntax
asserts.fields(s, expectedFields)
[res, msg] = asserts.fields(s, expectedFields)
📥Input Arguments
Parameter Description
s Structure value.
expectedFields Exact field name list. Field order is ignored.
📤Output Arguments
Parameter Description
res true if the assertion passes, false otherwise.
msg assertion failure message, empty on success.
📄Description

The assertion passes when s has no missing field and no extra field.

Use asserts.hasFields when extra fields are allowed.

💡Examples
Exact field set
S = struct('a', 1, 'b', 2); asserts.fields(S, {'b', 'a'});
Capture an extra field
S = struct('a', 1, 'b', 2); [res, msg] = asserts.fields(S, {'a'});
🔗See Also
asserts.hasFields
🕔Version History
Version Description
2.0.0 initial version
Edit this page on GitHub