matlab.unittest.qualifications.Verifiable.verifyLessThanOrEqual - Verify value is less than or equal to specified value - MATLAB (original) (raw)

Class: matlab.unittest.qualifications.Verifiable
Namespace: matlab.unittest.qualifications

Verify value is less than or equal to specified value

Syntax

Description

verifyLessThanOrEqual([testCase](#bt00qsr-1%5Fsep%5Fmw%5F8d5e73c7-bacb-46a7-a1c1-f24af91e6c03),[actual](#mw%5Fc86f7f38-871a-45fe-9a4f-2fa4f3816f79),[ceiling](#mw%5Fc072766a-5719-44da-a539-37c1369462e4)) verifies that all elements of actual are less than or equal to all elements of ceiling.

example

verifyLessThanOrEqual([testCase](#bt00qsr-1%5Fsep%5Fmw%5F8d5e73c7-bacb-46a7-a1c1-f24af91e6c03),[actual](#mw%5Fc86f7f38-871a-45fe-9a4f-2fa4f3816f79),[ceiling](#mw%5Fc072766a-5719-44da-a539-37c1369462e4),[diagnostic](#mw%5F16a3d3a7-9022-4047-8ffe-8da756a43bdb)) also associates the diagnostic information in diagnostic with the qualification.

example

Input Arguments

expand all

Test case, specified as a matlab.unittest.qualifications.Verifiable object. Because the matlab.unittest.TestCase class subclasses matlab.unittest.qualifications.Verifiable and inherits its methods, testCase is typically amatlab.unittest.TestCase object.

Diagnostic information to display when the qualification passes or fails, specified as a string array, character array, function handle, or array of matlab.automation.diagnostics.Diagnostic objects.

Depending on the test runner configuration, the testing framework can display diagnostics when the qualification passes or fails. By default, the framework displays diagnostics only when the qualification fails. You can override the default behavior by customizing the test runner. For example, use a DiagnosticsOutputPlugin instance to display both failing and passing event diagnostics.

Example: "My Custom Diagnostic"

Example: @dir

Examples

expand all

Create a test case for interactive testing.

testCase = matlab.unittest.TestCase.forInteractiveUse;

Verify that 2 is less than or equal to 3.

verifyLessThanOrEqual(testCase,2,3)

Verify that 3 is less than or equal to 3.

verifyLessThanOrEqual(testCase,3,3)

Test if 9 is less than or equal to 5. The test fails.

verifyLessThanOrEqual(testCase,9,5)

Verification failed. --------------------- Framework Diagnostic: --------------------- verifyLessThanOrEqual failed. --> The value must be less than or equal to the maximum value.

Actual Value:
     9
Maximum Value (Inclusive):
     5
------------------
Stack Information:
------------------
In C:\work\CompareTwoNumbersExample.m (CompareTwoNumbersExample) at 20

Create a test case for interactive testing.

testCase = matlab.unittest.TestCase.forInteractiveUse;

Test if each element of the vector [5 2 7] is less than or equal to the ceiling value 7.

verifyLessThanOrEqual(testCase,[5 2 7],7)

Test if each element of the matrix [1 2 3; 4 5 6] is less than or equal to the ceiling value 4.

verifyLessThanOrEqual(testCase,[1 2 3; 4 5 6],4, ... "All elements must be less than or equal to the ceiling value.")

Verification failed. ---------------- Test Diagnostic: ---------------- All elements must be less than or equal to the ceiling value. --------------------- Framework Diagnostic: --------------------- verifyLessThanOrEqual failed. --> Each element must be less than or equal to the maximum value.

    Failing Indices:
         4     6

Actual Value:
     1     2     3
     4     5     6
Maximum Value (Inclusive):
     4
------------------
Stack Information:
------------------
In C:\work\CompareArrayToScalarExample.m (CompareArrayToScalarExample) at 18

Create a test case for interactive testing.

testCase = matlab.unittest.TestCase.forInteractiveUse;

Test if each element of the array [5 -3 2] is less than or equal to each corresponding element of the ceiling array [5 -3 8].

verifyLessThanOrEqual(testCase,[5 -3 2],[5 -3 8])

Compare an array to itself.

verifyLessThanOrEqual(testCase,eye(2),eye(2))

Tips

Version History

Introduced in R2013a