Main Content

matlab.unittest.constraints.IsLessThan Class

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

Test if value is less than specified value

Description

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

Creation

Description

c = matlab.unittest.constraints.IsLessThan(ceilingValue) creates a constraint to test if a value is less than ceilingValue and sets the CeilingValue 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 IsLessThan constraint.

First, import the classes used in this example.

import matlab.unittest.TestCase
import matlab.unittest.constraints.IsLessThan

Create a test case for interactive testing.

testCase = TestCase.forInteractiveUse;

Verify that 2 is less than 3.

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

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

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

Verify that 2 is less than each element of the ceiling vector [5 6 7].

testCase.verifyThat(2,IsLessThan([5 6 7]))
Verification passed.

Test if each element of the vector [5 -3 2] is less than each corresponding element of the ceiling vector [7 -1 8]. The test passes.

testCase.verifyThat([5 -3 2],IsLessThan([7 -1 8]))
Verification passed.

Compare two equal arrays. The test fails.

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

Version History

Introduced in R2013a