matlab.unittest.constraints.LogicalComparator class
Package: matlab.unittest.constraints
Comparator for two logical values
Construction
LogicalComparator
creates
a comparator for two logical values. The comparator is satisfied if
the actual and expected values have the same sparsity and the logical
values are equivalent.
Copy Semantics
Value. To learn how value classes affect copy operations, see Copying Objects.
Examples
Tips
In most cases, you are not required to use a
LogicalComparator
object. TheIsEqualTo
class creates a constraint to test for equality between data of various types, including logical values.Use a
LogicalComparator
object 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 nonlogical, include aLogicalComparator
object in your test. You also can useLogicalComparator
to restrict the values contained in structures, cell arrays, and tables. In this example, MATLAB® throws an exception because the actual and expected values are numeric arrays.import matlab.unittest.constraints.IsEqualTo import matlab.unittest.constraints.LogicalComparator exp = magic(5); act = exp; testCase = matlab.unittest.TestCase.forInteractiveUse; testCase.verifyThat(act,IsEqualTo(exp,'Using',LogicalComparator))