Main Content

matlab.unittest.constraints.IsAnything class

Package: matlab.unittest.constraints
Superclasses: matlab.unittest.constraints.Constraint

Constraint specifying any value

Construction

IsAnything provides a constraint specifying any value. The constraint is satisfied by any value. It is the default constraint for selectors that do not require an input argument.

Copy Semantics

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

Examples

collapse all

Create a test case for interactive testing.

import matlab.unittest.TestCase
import matlab.unittest.constraints.IsAnything

testCase = TestCase.forInteractiveUse;

Verify that the following values satisfy the IsAnything constraint: NaN, an inputParser object, a numeric array, and a complex number.

testCase.verifyThat(NaN, IsAnything)
testCase.verifyThat(inputParser, IsAnything)
testCase.verifyThat(1:10, IsAnything)
testCase.verifyThat(-Inf+5j, IsAnything)
Interactive verification passed.
Interactive verification passed.
Interactive verification passed.
Interactive verification passed.

Test that empty cells, arrays, and character vectors satisfy the IsAnything constraint.

testCase.verifyThat({}, IsAnything)
testCase.verifyThat([], IsAnything)
testCase.verifyThat('', IsAnything)
Interactive verification passed.
Interactive verification passed.
Interactive verification passed.

The constraint is satisfied even though the data are empty.