matlab.unittest.constraints.IsEmpty class

Package: matlab.unittest.constraints
Superclasses: matlab.unittest.constraints.BooleanConstraint

Constraint specifying empty value


IsEmpty provides a constraint that specifies an empty value. The constraint is satisfied if the actual value array is empty.

Copy Semantics

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


collapse all

Create a test case for interactive testing.

import matlab.unittest.TestCase
import matlab.unittest.constraints.IsEmpty

testCase = TestCase.forInteractiveUse;

Verify that an empty character vector satisfies the IsEmpty constraint.

testCase.verifyThat('', IsEmpty)
Interactive verification passed.

Assert that a vector is not empty.

testCase.assertThat([13 42], ~IsEmpty)
Interactive verification passed.

Verify that a matrix with a dimension of length zero is empty.

testCase.verifyThat(rand(2, 5, 0, 3), IsEmpty)
Interactive verification passed.

Assert that an empty object satisfies the IsEmpty constraint.

testCase.assertThat(MException.empty, IsEmpty)
Interactive assertion passed.

Verify that a cell array containing an empty numeric array is empty.

testCase.verifyThat({[]}, IsEmpty)
Interactive verification failed.

Framework Diagnostic:
IsEmpty failed.
--> The value must be empty.
--> The value has a size of [1  1].

Actual Value:

The cell array is not empty, even though the only thing it contains is an empty array.