asserts.hasFields
Check that a structure has all expected fields.
📝Syntax
asserts.hasFields(s, expectedFields)
[res, msg] = asserts.hasFields(s, expectedFields)
📥Input Arguments
Parameter Description
s Structure value.
expectedFields Field name list as a character vector, string scalar, string array or cell of character vectors.
📤Output Arguments
Parameter Description
res true if the assertion passes, false otherwise.
msg assertion failure message, empty on success.
📄Description

The assertion passes when every expected field exists in s.

Extra fields in s are allowed.

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