matlab.unittest.constraints.IsFinite class

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

Constraint specifying finite value

Construction

IsFinite creates a constraint that is able to determine if all values of an actual value array are finite. This constraint is satisfied only if the actual value array does not contain any infinite or NaN values.

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.IsFinite

testCase = TestCase.forInteractiveUse;

Test that the value 17 satisfies the constraint.

testCase.verifyThat(17, IsFinite)
Interactive verification passed.

Assert that an array is completely finite.

testCase.assertThat([0 1 1 2 3 5 8 13], IsFinite)
Interactive assertion passed.

Verify that an array is completely finite.

testCase.verifyThat([-Inf 5 NaN], IsFinite)
Interactive verification failed.

---------------------
Framework Diagnostic:
---------------------
IsFinite failed.
--> All elements must be finite-valued.
    Failing indices:
             1     3

Actual Value:
      -Inf     5   NaN

The array contains an infinite value.

Test if a complex number that is infinite in the imaginary part satisfies the constraint.

testCase.assertThat(42+Inf*1i, IsFinite)
Interactive assertion failed.

---------------------
Framework Diagnostic:
---------------------
IsFinite failed.
--> The value must be finite.

Actual Value:
     42.000000000000000 +               Infi
Assertion failed.

Verify that an array does not contain all finite values.

testCase.verifyThat([NaN -7+NaN*1i], ~IsFinite)
Interactive verification passed.

See Also

| |