Package: matlab.unittest.constraints
Comparator for MATLAB structure arrays
StructComparator creates
a comparator for MATLAB® structure arrays.
StructComparator( indicates
a comparator, compObj)compObj, that defines the comparator
used to compare values contained in the structure. By default, a StructComparator supports
only empty structure arrays.
StructComparator( provides
a comparator with additional options specified by one or more compObj,Name,Value)Name,Value pair
arguments.
StructComparator( provides
a comparator for empty structure arrays with additional options specified
by one or more Name,Value)Name,Value pair arguments.
|
Fields to ignore during struct comparison, specified in the
name-value pair argument, |
|
Indicator of whether comparator operates recursively, specified
in the name-value pair argument, |
Value. To learn how value classes affect copy operations, see Copying Objects.
In most cases, you are not required to use a StructComparator
object. The IsEqualTo class creates a
constraint to test for equality between data of various types, including
structures.
Use a StructComparator object when you need to override the
comparison performed by the IsEqualTo class. For example, if
you want the comparison to fail when structures include nonnumeric values,
include a StructComparator object in your test. In this example,
MATLAB throws an exception because s1 and
s2 contain nonnumeric
values.
import matlab.unittest.constraints.IsEqualTo import matlab.unittest.constraints.StructComparator import matlab.unittest.constraints.NumericComparator s1 = struct('f1',zeros(1,10),'f2','a','f3',{'b','c'}); s2 = s1; testCase = matlab.unittest.TestCase.forInteractiveUse; testCase.verifyThat(s2,IsEqualTo(s1,'Using',StructComparator(NumericComparator)))