matlab.unittest.constraints.LogicalComparator Class
Namespace: matlab.unittest.constraints
Comparator for logical arrays
Description
The matlab.unittest.constraints.LogicalComparator
class provides a
comparator for logical arrays. To use this comparator in your tests, create a
LogicalComparator
instance, and specify it as the value of the
Using
name-value argument of the IsEqualTo
constraint constructor.
Creation
Description
c = matlab.unittest.constraints.LogicalComparator
creates a comparator for logical arrays. The comparator is satisfied if the actual and
expected values are logical arrays with the same size and sparsity, and their
corresponding elements are equal.
Examples
Tips
In most cases, you are not required to use a
LogicalComparator
instance. TheIsEqualTo
class creates a constraint to test for the equality of various data types, including logical arrays.Use a
LogicalComparator
instance when you need to override the comparison performed by theIsEqualTo
class. For example, if you want the comparison to fail when actual and expected values are not logical, include aLogicalComparator
instance in your test. You also can useLogicalComparator
to restrict the values contained in cell arrays, structures, dictionaries, tables, and public properties of MATLAB® object arrays. In this example, MATLAB throws an error because the actual and expected values are numeric arrays.import matlab.unittest.TestCase import matlab.unittest.constraints.IsEqualTo import matlab.unittest.constraints.LogicalComparator testCase = TestCase.forInteractiveUse; exp = magic(5); act = exp; testCase.verifyThat(act,IsEqualTo(exp,"Using",LogicalComparator))
Version History
Introduced in R2013a
See Also
matlab.unittest.constraints.IsEqualTo
| verifyThat
| isequal