matlab.unittest.constraints.IsLessThan class

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

Constraint specifying value less than another value

Construction

IsLessThan(ceilVal) creates a constraint specifying that an actual value is less than another value. The constraint is satisfied if the actual value array is less than the specified ceiling value, ceilVal. The actual value is less than ceilVal only if the result of the expression actual < ceilVal is nonempty and all values are true.

Input Arguments

ceilVal

Smallest value that fails the constraint.

Properties

CeilingValue

Smallest value that fails the constraint. Set this property through the constructor via the ceilVal input argument.

Methods

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

testCase = TestCase.forInteractiveUse;

Test that the actual value is less than four.

actVal = 3;
testCase.verifyThat(actVal, IsLessThan(4))
Interactive verification passed.

Test that the actual value is less than three.

testCase.verifyThat(actVal, IsLessThan(3))
Interactive verification failed.

---------------------
Framework Diagnostic:
---------------------
IsLessThan failed.
--> The value must be less than the maximum value.

Actual double:
         3
Maximum Value (Exclusive):
         3

The actual value is equal to, not less than, three.

Test that each element in the actual value array is less than four.

actVal = [1 2 3];
testCase.verifyThat(actVal, IsLessThan(4))
Interactive verification passed.

Test that each element in the actual value matrix is less than four.

actVal = [1 2 3; 4 5 6];
testCase.verifyThat(actVal, IsLessThan(4))
Interactive verification failed.

---------------------
Framework Diagnostic:
---------------------
IsLessThan failed.
--> Each element must be less than the maximum value.
    
    Failing Indices:
             2     4     6

Actual double:
         1     2     3
         4     5     6
Maximum Value (Exclusive):
         4

The matrix contains three elements that are greater than or equal to four.

Test that the actual value, 0, is less than every element in an array.

testCase.verifyThat(0, IsLessThan([1 2 3]))
Interactive verification passed.

Test that elements in the actual value array are less than the corresponding ceiling values.

testCase.verifyThat([4 -9 0], IsLessThan([5 -3 2]))
Interactive verification passed.

Repeat the test, this time negating the second actual value element.

testCase.verifyThat([4 9 0], IsLessThan([5 -3 2]))
Interactive verification failed.

---------------------
Framework Diagnostic:
---------------------
IsLessThan failed.
--> Each element must be less than each corresponding element of the maximum value array.
    
    Failing Indices:
             2

Actual double:
         4     9     0
Maximum Value (Exclusive):
         5    -3     2

The negated element is greater than -3.