Main Content

matlab.unittest.constraints Namespace

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 namespace to select Test elements and with the mocking framework to specify behavior and qualify interactions.

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

Classes

Constraint Implementations

Fundamental Constraint-Related Interfaces

matlab.unittest.constraints.BooleanConstraintFundamental interface for constraints that support Boolean operations
matlab.unittest.constraints.ConstraintFundamental interface for constraints

General Purpose

matlab.unittest.constraints.EventuallyTest if function asynchronously satisfies constraint
matlab.unittest.constraints.HasFieldTest if structure array has specified field
matlab.unittest.constraints.IsAnythingTest for any value
matlab.unittest.constraints.IsEqualToConstraint to test for equality
matlab.unittest.constraints.IsFalseTest if value is false
matlab.unittest.constraints.IsSameHandleAsTest if two handle arrays are the same
matlab.unittest.constraints.IsTrueTest if value is true
matlab.unittest.constraints.IsValidTest if array elements are valid handles
matlab.unittest.constraints.ReturnsTrueTest if function returns true

Errors and Warnings

matlab.unittest.constraints.IssuesNoWarningsTest if function issues no warnings
matlab.unittest.constraints.IssuesWarningsTest if function issues specified warnings
matlab.unittest.constraints.ThrowsTest if function throws specified error

Inequalities

matlab.unittest.constraints.IsGreaterThanTest if value is greater than specified value
matlab.unittest.constraints.IsGreaterThanOrEqualToTest if value is greater than or equal to specified value
matlab.unittest.constraints.IsLessThanTest if value is less than specified value
matlab.unittest.constraints.IsLessThanOrEqualToTest if value is less than or equal to specified value

Array Size

matlab.unittest.constraints.HasElementCountTest if array has specified number of elements
matlab.unittest.constraints.HasLengthTest if array has specified length
matlab.unittest.constraints.HasSizeTest if array has specified size
matlab.unittest.constraints.IsEmptyTest if value is empty
matlab.unittest.constraints.IsScalarTest if value is scalar

Type

matlab.unittest.constraints.IsInstanceOfTest if value is instance of specified class
matlab.unittest.constraints.IsOfClassTest if class of value is specified class

Strings

matlab.unittest.constraints.ContainsSubstringTest if value contains specified string
matlab.unittest.constraints.EndsWithSubstringTest if value ends with specified string
matlab.unittest.constraints.IsSubstringOfTest if value is substring of specified string
matlab.unittest.constraints.MatchesTest if value matches specified regular expression
matlab.unittest.constraints.StartsWithSubstringTest if value starts with specified string

Special Values

matlab.unittest.constraints.HasInfTest if array has infinite values
matlab.unittest.constraints.HasMissingTest if array has missing elements
matlab.unittest.constraints.HasNaNTest if array has NaN values
matlab.unittest.constraints.IsFiniteTest if array elements are finite values

Numeric Attributes

matlab.unittest.constraints.IsRealTest if array elements are real values
matlab.unittest.constraints.IsSparseTest if array is sparse

Set

matlab.unittest.constraints.HasUniqueElementsTest if set has unique elements
matlab.unittest.constraints.IsSameSetAsTest if set has same elements as another set
matlab.unittest.constraints.IsSubsetOfTest if set is subset of specified set
matlab.unittest.constraints.IsSupersetOfTest if set is superset of specified set

Files and Folders

Actual Value Proxies

matlab.unittest.constraints.AnyCellOfTest if any element of cell array satisfies constraint
matlab.unittest.constraints.AnyElementOfTest if any element of array satisfies constraint
matlab.unittest.constraints.EveryCellOfTest if every element of cell array satisfies constraint
matlab.unittest.constraints.EveryElementOfTest if every element of array satisfies constraint

Tolerances

matlab.unittest.constraints.AbsoluteToleranceAbsolute numeric tolerance
matlab.unittest.constraints.AndToleranceLogical conjunction of numeric tolerances
matlab.unittest.constraints.OrToleranceLogical disjunction of numeric tolerances
matlab.unittest.constraints.RelativeToleranceRelative numeric tolerance
matlab.unittest.constraints.ToleranceFundamental interface for tolerances

Comparators

matlab.unittest.constraints.CellComparatorComparator for cell arrays
matlab.unittest.constraints.DictionaryComparatorComparator for dictionaries
matlab.unittest.constraints.LogicalComparatorComparator for logical arrays
matlab.unittest.constraints.NumericComparatorComparator for numeric arrays
matlab.unittest.constraints.ObjectComparatorComparator for MATLAB or Java object arrays
matlab.unittest.constraints.PublicPropertyComparatorComparator for public properties of MATLAB object arrays
matlab.unittest.constraints.StringComparatorComparator for string arrays, character arrays, or cell arrays of character arrays
matlab.unittest.constraints.StructComparatorComparator for structure arrays
matlab.unittest.constraints.TableComparatorComparator for table arrays

Version History

Introduced in R2013a