matlab.unittest.constraints.IsFalse class

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

Constraint specifying false value

Construction

IsFalse provides a constraint specifying a false value. This constraint is satisfied only by a scalar logical with a value of false.

Copy Semantics

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

Examples

expand all

Test Actual Value Is False

Create a test case for interactive testing.

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

testCase = TestCase.forInteractiveUse;

Test that false satisfies the IsFalse constraint.

testCase.verifyThat(false, IsFalse)
Interactive verification passed.

Test that the IsFalse constraint is not satisfied by true.

testCase.verifyThat(true, IsFalse)
Interactive verification failed.

---------------------
Framework Diagnostic:
---------------------
IsFalse failed.
--> The value must evaluate to "false".

Actual Value:
         1

The test fails because true returns logical(1).

Test that the IsFalse constraint is not satisfied by the double 0.

testCase.verifyThat(0, IsFalse)
Interactive verification failed.

---------------------
Framework Diagnostic:
---------------------
IsFalse failed.
--> The value must be logical. It is of type "double".

Actual Value:
         0

The IsFalse constraint is satisfied only by logical(0).

Test that the IsFalse constraint is not satisfied by a logical array of zeros.

testCase.verifyThat([false false false], IsFalse)
Interactive verification failed.

---------------------
Framework Diagnostic:
---------------------
IsFalse failed.
--> The value must be scalar. It has a size of [1  3].

Actual Value:
         0     0     0

The IsFalse constraint is only satisfied if the value is scalar and logical(0).

See Also

Was this topic helpful?