matlab.unittest.constraints.IsTrue Class
Namespace: matlab.unittest.constraints
Superclasses: matlab.unittest.constraints.Constraint
Test if value is true
Description
The matlab.unittest.constraints.IsTrue
class provides a constraint to test
if a value is true.
Creation
Description
c = matlab.unittest.constraints.IsTrue
creates a
constraint to test if a value is true. The constraint is satisfied by a logical scalar
value of 1
(true
).
Examples
Tips
An alternative to
IsTrue
is theReturnsTrue
constraint.IsTrue
runs faster and is easier to use, butReturnsTrue
provides slightly better diagnostic information. In this example, both tests fail, but the second test displays the function handle as part of the diagnostics.import matlab.unittest.TestCase import matlab.unittest.constraints.IsTrue import matlab.unittest.constraints.ReturnsTrue testCase = TestCase.forInteractiveUse; actual = 1; expected = 2; testCase.verifyThat(isequal(actual,expected),IsTrue) testCase.verifyThat(@() isequal(actual,expected),ReturnsTrue)
Version History
Introduced in R2013a