matlab.unittest.constraints.IsGreaterThanOrEqualTo class

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

Constraint specifying value greater than or equal to another value

Construction

IsGreaterThanOrEqualTo(floorVal) creates a constraint specifying that an actual value is greater than or equal to another value. The constraint is satisfied if the actual value array is greater than or equal to the specified floor value, floorVal. The actual value is greater than or equal to floorVal only if the result of the expression actual >= floorVal is nonempty and all values are true.

Input Arguments

floorVal

Minimum value to satisfy the constraint.

Properties

FloorValue

Minimum value to satisfy the constraint. Set this property through the constructor via the floorVal 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.IsGreaterThanOrEqualTo

testCase = TestCase.forInteractiveUse;

Test that the actual value is greater than or equal to two.

actVal = 3;
testCase.verifyThat(actVal, IsGreaterThanOrEqualTo(2))
Interactive verification passed.

Test that the actual value is greater than or equal to three.

testCase.verifyThat(actVal, IsGreaterThanOrEqualTo(3))
Interactive verification passed.

Test that each element in the actual value array is greater than or equal to four.

actVal = [5 6 7];
testCase.verifyThat(actVal, IsGreaterThanOrEqualTo(4))
Interactive verification passed.

Test that each element in the actual value matrix is greater than or equal to four.

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

---------------------
Framework Diagnostic:
---------------------
IsGreaterThanOrEqualTo failed.
--> Each element must be greater than or equal to the minimum value.
    
    Failing Indices:
             1     3     5

Actual double:
         1     2     3
         4     5     6
Minimum Value (Inclusive):
         4

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

Test that the actual value, 5, is greater than or equal to every element in an array.

testCase.verifyThat(5, IsGreaterThanOrEqualTo([1 2 3 5]))
Interactive verification passed.

Test that elements in the actual value array are greater than or equal to the corresponding floor values.

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

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

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

---------------------
Framework Diagnostic:
---------------------
IsGreaterThanOrEqualTo failed.
--> Each element must be greater than or equal to each corresponding element of the minimum value array.
    
    Failing Indices:
             1

Actual double:
        -5    -3     0
Minimum Value (Inclusive):
         4    -9     0

The negated element is less than or equal to four.