Main Content

matlab.unittest.constraints.IsFalse Class

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

Test if value is false

Description

The matlab.unittest.constraints.IsFalse class provides a constraint to test if a value is false.

Creation

Description

c = matlab.unittest.constraints.IsFalse creates a constraint to test if a value is false. The constraint is satisfied by a logical scalar value of 0 (false).

example

Examples

collapse all

Test values using the IsFalse constraint.

First, import the classes used in this example.

import matlab.unittest.TestCase
import matlab.unittest.constraints.IsFalse

Create a test case for interactive testing.

testCase = TestCase.forInteractiveUse;

Verify that false satisfies the IsFalse constraint.

testCase.verifyThat(false,IsFalse)
Verification passed.

Test if true satisfies the constraint. The test fails.

testCase.verifyThat(true,IsFalse)
Verification failed.
    ---------------------
    Framework Diagnostic:
    ---------------------
    IsFalse failed.
    --> The value must evaluate to "false".
    
    Actual Value:
      logical
    
       1

Test the value 0. The test fails because the value is of type double.

testCase.verifyThat(0,IsFalse)
Verification failed.
    ---------------------
    Framework Diagnostic:
    ---------------------
    IsFalse failed.
    --> The value must be logical. It is of type "double".
    
    Actual Value:
         0

Test the value [false false]. The test fails because the value is nonscalar.

testCase.verifyThat([false false],IsFalse)
Verification failed.
    ---------------------
    Framework Diagnostic:
    ---------------------
    IsFalse failed.
    --> The value must be scalar. It has a size of [1  2].
    
    Actual Value:
      1×2 logical array
    
       0   0

Version History

Introduced in R2013a