matlab.unittest.qualifications.Verifiable.verifyGreaterThan - Verify value is greater than specified value - MATLAB (original) (raw)

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

Verify value is greater than specified value

Syntax

Description

verifyGreaterThan([testCase](#bt00qcj-1%5Fsep%5Fmw%5F8d5e73c7-bacb-46a7-a1c1-f24af91e6c03),[actual](#mw%5F475e3bd0-34f3-40f7-a637-9cc3f542021f),[floor](#mw%5Fa3363b6c-e801-4b76-b7e6-102be4b185ce)) verifies that all elements of actual are greater than all elements offloor.

example

verifyGreaterThan([testCase](#bt00qcj-1%5Fsep%5Fmw%5F8d5e73c7-bacb-46a7-a1c1-f24af91e6c03),[actual](#mw%5F475e3bd0-34f3-40f7-a637-9cc3f542021f),[floor](#mw%5Fa3363b6c-e801-4b76-b7e6-102be4b185ce),[diagnostic](#mw%5F324d33e2-1f97-42dc-8fe6-5c6462a84b86)) 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 2.

verifyGreaterThan(testCase,3,2)

Test if 5 is greater than 9. The test fails.

verifyGreaterThan(testCase,5,9)

Verification failed. --------------------- Framework Diagnostic: --------------------- verifyGreaterThan failed. --> The value must be greater than the minimum value.

Actual Value:
     5
Minimum Value (Exclusive):
     9
------------------
Stack Information:
------------------
In C:\work\CompareTwoNumbersExample.m (CompareTwoNumbersExample) at 16

Create a test case for interactive testing.

testCase = matlab.unittest.TestCase.forInteractiveUse;

Test if each element of the vector [5 6 7] is greater than the floor value 2.

verifyGreaterThan(testCase,[5 6 7],2)

Test if 5 is greater than each element of the floor vector [1 2 3].

verifyGreaterThan(testCase,5,[1 2 3])

Test if each element of the matrix [1 2 3; 4 5 6] is greater than the floor value 4. The test fails.

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

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

    Failing Indices:
         1     2     3     5

Actual Value:
     1     2     3
     4     5     6
Minimum Value (Exclusive):
     4
------------------
Stack Information:
------------------
In C:\work\CompareArrayToScalarExample.m (CompareArrayToScalarExample) at 22

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 each corresponding element of the floor array [4 -9 0] .

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

Compare an array to itself. The test fails.

verifyGreaterThan(testCase,eye(2),eye(2))

Verification failed. --------------------- Framework Diagnostic: --------------------- verifyGreaterThan failed. --> Each element must be greater than each corresponding element of the minimum value array.

    Failing Indices:
         1     2     3     4

Actual Value:
     1     0
     0     1
Minimum Value (Exclusive):
     1     0
     0     1
------------------
Stack Information:
------------------
In C:\work\CompareArraysExample.m (CompareArraysExample) at 17

Tips

Version History

Introduced in R2013a