Accelerating the pace of engineering and science

# Documentation Center

• Trial Software
• Product Updates

# matlab.unittest.constraints.HasInf class

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

Constraint specifying array containing any infinite value

## Description

The HasInf class creates a constraint that is able to determine whether any value of an actual value array is an infinite value. It is only satisfied if the actual value array contains at least one infinite value.

## Construction

HasInf provides a constraint specifying an array containing any infinite value. This constraint is only satisfied if the actual value array contains at least one infinite value.

## Copy Semantics

Value. To learn how value classes affect copy operations, see Copying Objects in the MATLAB® documentation.

## Examples

expand all

### Instantiate HasInf Object

```import matlab.unittest.constraints.HasInf;

% Create a TestCase for interactive use
testCase = matlab.unittest.TestCase;

% Passing scenarios
%%%%%%%%%%%%%%%%%%%%
testCase.verifyThat(Inf, HasInf);
testCase.verifyThat(-Inf, HasInf);
testCase.verifyThat([-Inf Inf], HasInf);
testCase.verifyThat([4 Inf], HasInf);
testCase.verifyThat([-Inf 5 NaN], HasInf);
testCase.verifyThat(NaN+Inf*i, HasInf);

% Failing scenarios
%%%%%%%%%%%%%%%%%%%%
testCase.verifyThat(NaN, HasInf);
testCase.verifyThat([5 NaN], HasInf);
testCase.verifyThat(NaN+6i, HasInf);
testCase.verifyThat([5 6 NaN 8], HasInf);
testCase.verifyThat([5 6 7 8], HasInf);```

## See Also

Was this topic helpful?