Main Content

matlab.unittest.constraints Package

Summary of classes in MATLAB Constraints Interface

Description

You can use constraints to specify business rules for qualifying calculated (actual) values in tests. To test whether or not an actual value satisfies a constraint, use the constraint in conjunction with the matlab.unittest.qualifications qualification methods assertThat, assumeThat, fatalAssertThat, or verifyThat. While constraints are primarily intended for qualifications, you also can use them with the classes in the matlab.unittest.selectors package to select test elements and with the mocking framework to specify behavior and qualify interactions.

The matlab.unittest.constraints package consists of the following classes.

Classes

Constraint Implementations

Fundamental Constraint-Related Interfaces

matlab.unittest.constraints.BooleanConstraintInterface class for Boolean combinations of constraints
matlab.unittest.constraints.ConstraintFundamental interface class for comparisons

General Purpose

matlab.unittest.constraints.EventuallyPoll for value to asynchronously satisfy constraint
matlab.unittest.constraints.HasFieldConstraint specifying structure containing particular field
matlab.unittest.constraints.IsAnythingConstraint specifying any value
matlab.unittest.constraints.IsEqualToGeneral constraint to compare for equality
matlab.unittest.constraints.IsFalseConstraint specifying false value
matlab.unittest.constraints.IsSameHandleAsConstraint specifying handle instance same as another
matlab.unittest.constraints.IsTrueConstraint specifying true value
matlab.unittest.constraints.ReturnsTrueConstraint specifying function handle that returns true

Errors and Warnings

matlab.unittest.constraints.IssuesNoWarningsConstraint specifying function that issues no warnings
matlab.unittest.constraints.IssuesWarningsConstraint specifying function that issues expected warning profile
matlab.unittest.constraints.ThrowsConstraint specifying function handle that throws MException

Inequalities

matlab.unittest.constraints.IsGreaterThanConstraint specifying value greater than another value
matlab.unittest.constraints.IsGreaterThanOrEqualToConstraint specifying value greater than or equal to another value
matlab.unittest.constraints.IsLessThanConstraint specifying value less than another value
matlab.unittest.constraints.IsLessThanOrEqualToConstraint specifying value less than or equal to another value

Array Size

matlab.unittest.constraints.HasElementCountConstraint specifying expected number of elements
matlab.unittest.constraints.HasLengthConstraint specifying expected length of array
matlab.unittest.constraints.HasSizeConstraint specifying expected size of array
matlab.unittest.constraints.IsEmptyConstraint specifying empty value
matlab.unittest.constraints.IsScalarConstraint specifying scalar value

Type

matlab.unittest.constraints.IsInstanceOfConstraint specifying inclusion in given class hierarchy
matlab.unittest.constraints.IsOfClassConstraint specifying class type

Strings

matlab.unittest.constraints.ContainsSubstringConstraint specifying string containing substring
matlab.unittest.constraints.EndsWithSubstringConstraint specifying string ending with substring
matlab.unittest.constraints.IsSubstringOfConstraint specifying substring of another string
matlab.unittest.constraints.MatchesConstraint specifying string matches regular expression
matlab.unittest.constraints.StartsWithSubstringConstraint specifying string starting with substring

Finiteness

matlab.unittest.constraints.HasInfConstraint specifying array containing any infinite value
matlab.unittest.constraints.HasNaNConstraint specifying array containing NaN value
matlab.unittest.constraints.IsFiniteConstraint specifying finite value

Numeric Attributes

matlab.unittest.constraints.IsRealConstraint specifying real valued array
matlab.unittest.constraints.IsSparseConstraint specifying sparse array

Set

matlab.unittest.constraints.HasUniqueElementsConstraint specifying set contains unique elements
matlab.unittest.constraints.IsSameSetAsConstraint specifying set contains same elements as another set
matlab.unittest.constraints.IsSubsetOfConstraint specifying actual set is subset of expected set
matlab.unittest.constraints.IsSupersetOfConstraint specifying actual set is superset of expected set

Files and Folders

matlab.unittest.constraints.IsFile Constraint specifying value points to file
matlab.unittest.constraints.IsFolderConstraint specifying value points to folder

Actual Value Proxies

matlab.unittest.constraints.AnyCellOfTest if any element of cell array meets constraint
matlab.unittest.constraints.AnyElementOfTest if any element of array meets constraint
matlab.unittest.constraints.EveryCellOfTest if all elements of cell array meet constraint
matlab.unittest.constraints.EveryElementOfTest if all elements of array meet constraint

Tolerances

matlab.unittest.constraints.AbsoluteToleranceAbsolute numeric tolerance
matlab.unittest.constraints.RelativeToleranceRelative numeric tolerance
matlab.unittest.constraints.ToleranceAbstract interface class for tolerances

Comparators

matlab.unittest.constraints.CellComparatorComparator for cell arrays
matlab.unittest.constraints.LogicalComparatorComparator for two logical values
matlab.unittest.constraints.NumericComparatorComparator for numeric data types
matlab.unittest.constraints.ObjectComparatorComparator for MATLAB or Java objects
matlab.unittest.constraints.PublicPropertyComparatorComparator for public properties of MATLAB objects
matlab.unittest.constraints.StringComparatorComparator for two strings, character arrays, or cell arrays of character arrays
matlab.unittest.constraints.StructComparatorComparator for MATLAB structure arrays
matlab.unittest.constraints.TableComparatorComparator for MATLAB tables
Introduced in R2013a