Main Content

matlab.unittest.constraints.IsGreaterThan Class

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

Test if value is greater than specified value

Description

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

Creation

Description

c = matlab.unittest.constraints.IsGreaterThan(floorValue) creates a constraint to test if a value is greater than 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 IsGreaterThan constraint.

First, import the classes used in this example.

import matlab.unittest.TestCase
import matlab.unittest.constraints.IsGreaterThan

Create a test case for interactive testing.

testCase = TestCase.forInteractiveUse;

Verify that 3 is greater than 2.

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

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

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

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

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

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

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

Compare two equal arrays. The test fails.

testCase.verifyThat(eye(2),IsGreaterThan(eye(2)))
Verification failed.
    ---------------------
    Framework Diagnostic:
    ---------------------
    IsGreaterThan failed.
    --> Each element must be greater than each corresponding element of the minimum value array.
        
        Failing Indices:
             1     2     3     4
    
    Actual Value:
         1     0
         0     1
    Minimum Value (Exclusive):
         1     0
         0     1

Version History

Introduced in R2013a