matlab.unittest.constraints.IsTrue 类
命名空间: matlab.unittest.constraints
超类: matlab.unittest.constraints.Constraint
测试值是否为 true
描述
matlab.unittest.constraints.IsTrue
类提供一个约束来测试值是否为 true。
创建对象
描述
c = matlab.unittest.constraints.IsTrue
创建一个约束来测试值是否为 true。标量逻辑值 1
(true
) 满足该约束。
示例
提示
IsTrue
的替代约束是ReturnsTrue
约束。IsTrue
运行速度更快,更易于使用,但ReturnsTrue
提供的诊断信息稍好。在此示例中,两个测试都失败,但第二个测试将函数句柄显示为诊断的一部分。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)
版本历史记录
在 R2013a 中推出