matlab.unittest.constraints.IsGreaterThan class

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

Constraint specifying value greater than another value

Construction

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

Input Arguments

floorVal

Largest value that fails the constraint.

Properties

FloorValue

Largest value that fails the constraint. Set this property through the constructor via the floorVal input argument.

Methods

andForm logical conjunction of constraints
orForm logical disjunction of constraints

Copy Semantics

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

Examples

expand all

Test That Actual Value Is Greater Than Provided Floor Value

Create a test case for interactive testing.

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

testCase = TestCase.forInteractiveUse;

Test that the actual value is greater than two.

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

Test that the actual value is greater than three.

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

---------------------
Framework Diagnostic:
---------------------
IsGreaterThan failed.
--> The value must be greater than the minimum value.

Actual Value:
         3
Minimum Value (Exclusive):
         3

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

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

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

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

actVal = [1 2 3; 4 5 6];
testCase.verifyThat(actVal, IsGreaterThan(4))
Interactive 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

The matrix contains four elements with a value less than or equal to four.

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

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

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

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

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

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

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

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

The negated element is less than four.

Was this topic helpful?