Main Content

matlab.unittest.constraints.Tolerance class

Package: matlab.unittest.constraints

Abstract interface class for tolerances


Tolerances define a notion of fuzzy equality for a set of data types and can be plugged in to the IsEqualTo constraint through the 'Within' name-value pair argument.

Classes that derive from the Tolerance interface class must provide a tolerance definition. Use the satisfiedBy method to implement the tolerance definition. Classes that derive from the Tolerance class also must provide a diagnostic for two compared values. The testing framework uses the diagnostic when the compared values are outside of the allowable tolerance. Use the getDiagnosticFor method to implement this condition. Finally, classes that derive from the Tolerance class must provide a means to determine which data types the tolerance supports. Define the supported data types by implementing the supports method.


getDiagnosticForProduce diagnostic for two values specified to be within tolerance
satisfiedByDetermine whether two values are within tolerance
supportsDetermine whether tolerance supports specified data type

Copy Semantics

Value. To learn how value classes affect copy operations, see Copying Objects.