matlab.unittest.constraints.TableComparator class
Package: matlab.unittest.constraints
Comparator for MATLAB tables
Construction
TableComparator
creates a comparator for MATLAB® tables
that iterates over each column of the table. By default, a TableComparator
supports
only empty tables.
TableComparator(
indicates
a comparator, compObj
)compObj
, that defines the comparator
used to compare values contained in the table columns.
TableComparator(___,
provides
a comparator with additional options specified by one or more Name,Value
)Name,Value
pair
arguments. Use this option with any of the input argument combinations
in the previous syntaxes.
Input Arguments
Properties
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
TableComparator
object. TheIsEqualTo
class creates a constraint to test for equality between data of various types, including tables.Use a
TableComparator
object when you need to override the comparison performed by theIsEqualTo
class. For example, if you want the comparison to fail when tables include nonnumeric values, include aTableComparator
object in your test. In this example, MATLAB throws an exception becauseT1
andT2
contain nonnumeric values.import matlab.unittest.constraints.IsEqualTo import matlab.unittest.constraints.TableComparator import matlab.unittest.constraints.NumericComparator T1 = table([45;32;34],logical([1;0;0]),'VariableNames',{'Age','Vote'}); T2 = T1; testCase = matlab.unittest.TestCase.forInteractiveUse; testCase.verifyThat(T2,IsEqualTo(T1,'Using',TableComparator(NumericComparator)))