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

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

Verify value is greater than or equal to specified value

Syntax

Description

verifyGreaterThanOrEqual([testCase](#bt00qe6-1%5Fsep%5Fmw%5F8d5e73c7-bacb-46a7-a1c1-f24af91e6c03),[actual](#mw%5Ff1e348a9-fab2-4158-833b-ce1e453728eb),[floor](#mw%5F88c4051f-45fe-46ac-93e3-0e256d1c17c1)) verifies that all elements of actual are greater than or equal to all elements of floor.

example

verifyGreaterThanOrEqual([testCase](#bt00qe6-1%5Fsep%5Fmw%5F8d5e73c7-bacb-46a7-a1c1-f24af91e6c03),[actual](#mw%5Ff1e348a9-fab2-4158-833b-ce1e453728eb),[floor](#mw%5F88c4051f-45fe-46ac-93e3-0e256d1c17c1),[diagnostic](#mw%5F189b6f72-763d-4ee7-8f93-722d634b0213)) 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 3 is greater than or equal to 2.

verifyGreaterThanOrEqual(testCase,3,2)

Verify that 3 is greater than or equal to 3.

verifyGreaterThanOrEqual(testCase,3,3)

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

verifyGreaterThanOrEqual(testCase,5,9)

Verification failed. --------------------- Framework Diagnostic: --------------------- verifyGreaterThanOrEqual failed. --> The value must be greater than or equal to the minimum value.

Actual Value:
     5
Minimum Value (Inclusive):
     9
------------------
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 greater than or equal to the floor value 2.

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

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

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

Verification failed. ---------------- Test Diagnostic: ---------------- All elements must be greater than or equal to the floor value. --------------------- Framework Diagnostic: --------------------- verifyGreaterThanOrEqual failed. --> Each element must be greater than or equal to the minimum value.

    Failing Indices:
         1     3     5

Actual Value:
     1     2     3
     4     5     6
Minimum 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 greater than or equal to each corresponding element of the floor array [4 -3 0].

verifyGreaterThanOrEqual(testCase,[5 -3 2],[4 -3 0])

Compare an array to itself.

verifyGreaterThanOrEqual(testCase,eye(2),eye(2))

Tips

Version History

Introduced in R2013a