Main Content

matlab.unittest.constraints.IsGreaterThanOrEqualTo Class

Namespace: matlab.unittest.constraints
Superclasses: matlab.unittest.constraints.Constraint

Test if value is greater than or equal to specified value

Description

The matlab.unittest.constraints.IsGreaterThanOrEqualTo class provides a constraint to test if a numeric value is greater than or equal to another value.

Creation

Description

c = matlab.unittest.constraints.IsGreaterThanOrEqualTo(floorValue) creates a constraint to test if a value is greater than or equal to floorValue and sets the FloorValue property. The sizes of the values being compared must be the same or be compatible. For more information about compatible arrays, see Compatible Array Sizes for Basic Operations.

example

Properties

expand all

Value to compare against, returned as a numeric array. Specify the value of this property during creation of the constraint.

Attributes:

GetAccess
public
SetAccess
private

Examples

collapse all

Compare numeric values using the IsGreaterThanOrEqualTo constraint.

First, import the classes used in this example.

import matlab.unittest.TestCase
import matlab.unittest.constraints.IsGreaterThanOrEqualTo

Create a test case for interactive testing.

testCase = TestCase.forInteractiveUse;

Verify that 3 is greater than or equal to 2.

testCase.verifyThat(3,IsGreaterThanOrEqualTo(2))
Verification passed.

Test if each element of the matrix [1 2 3; 4 5 6] is greater than or equal to the floor value 4. The test fails.

testCase.verifyThat([1 2 3; 4 5 6],IsGreaterThanOrEqualTo(4))
Verification failed.
    ---------------------
    Framework Diagnostic:
    ---------------------
    IsGreaterThanOrEqualTo failed.
    --> Each element must be greater than or equal to the minimum value.
        
        Failing Indices:
             1     3     5
    
    Actual Value:
         1     2     3
         4     5     6
    Minimum Value (Inclusive):
         4

Verify that 5 is greater than or equal to each element of the floor vector [1 3 5].

testCase.verifyThat(5,IsGreaterThanOrEqualTo([1 3 5]))
Verification passed.

Test if each element of the vector [5 -3 2] is greater than or equal to each corresponding element of the floor vector [4 -3 0]. The test passes.

testCase.verifyThat([5 -3 2],IsGreaterThanOrEqualTo([4 -3 0]))
Verification passed.

Compare two equal arrays. The test passes.

testCase.verifyThat(eye(2),IsGreaterThanOrEqualTo(eye(2)))
Verification passed.

Version History

Introduced in R2013a