Main Content

matlab.unittest.constraints.IsAnything Class

Namespace: matlab.unittest.constraints
Superclasses: matlab.unittest.constraints.Constraint

Test for any value

Description

The matlab.unittest.constraints.IsAnything class provides a constraint to test for any value.

Creation

Description

c = matlab.unittest.constraints.IsAnything creates a constraint that is satisfied by any value.

example

Examples

collapse all

Test if the actual value is any value by using the IsAnything constraint.

First, import the classes used in this example.

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

Create a test case for interactive testing.

testCase = TestCase.forInteractiveUse;

Verify that an empty array satisfies the IsAnything constraint.

testCase.verifyThat([],IsAnything)
Verification passed.

Verify that a function handle satisfies the IsAnything constraint.

testCase.verifyThat(@dir,IsAnything)
Verification passed.

Verify that a cell array satisfies the IsAnything constraint.

testCase.verifyThat({NaN,'',@myFun},IsAnything)
Verification passed.

Tips

  • Classes in the matlab.unittest.selectors namespace that do not require inputs use IsAnything as the default constraint.

  • For an example of how to use IsAnything in tests created with the mocking framework, see Create Mock Object.

Version History

Introduced in R2014a

See Also

Functions

Namespaces