Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

matlab.unittest.constraints.IssuesNoWarnings class

Package: matlab.unittest.constraints
Superclasses: matlab.unittest.constraints.Constraint

Constraint specifying function that issues no warnings

Construction

outConstObj = IssuesNoWarnings creates a constraint, outConstObj, specifying a function that issues no warnings when the testing framework invokes it. The constraint is satisfied if no warnings are issued when the testing framework invokes the function.

outConstObj = IssuesNoWarnings('WhenNargoutIs', numOutputs) creates a constraint that can determine if the actual value is a function handle that issues no warnings when the testing framework invokes it with a particular number of output arguments, numOutputs.

Input Arguments

numOutputs

Number of outputs the constraint requests when invoking the function handle, specified as a non-negative, real, scalar integer.

Default: 0

Properties

FunctionOutputs

Output arguments produced at invocation of the supplied function handle, specified as a cell array. This property provides access to output arguments. It is read only and the testing framework sets it when it invokes the function handle. The number of outputs is determined by the Nargout property.

Nargout

Number of output arguments the instance uses when executing functions. Set this property through the constructor via the numOutputs input argument.

Copy Semantics

Handle. To learn how handle classes affect copy operations, see Copying Objects in the MATLAB® documentation.

Examples

expand all

Instantiate IssuesNoWarnings Constraint

Create a test case for interactive testing.

import matlab.unittest.TestCase
import matlab.unittest.constraints.IssuesNoWarnings

testCase = TestCase.forInteractiveUse;

Verify that a call to true does not result in any warning.

testCase.verifyThat(@true, IssuesNoWarnings)
Interactive verification passed.

Verify that a call to size with an empty array does not result in any warning. Examine the output arguments.

issuesNoWarningsConstraint = IssuesNoWarnings('WhenNargoutIs', 2);
testCase.verifyThat(@() size([]), issuesNoWarningsConstraint)
[actualOut1, actualOut2] = issuesNoWarningsConstraint.FunctionOutputs{:};
Interactive verification passed.

Verify that the constraint is not satisfied if the actual value is not a function handle.

testCase.verifyThat(5, IssuesNoWarnings)
Interactive verification failed.

---------------------
Framework Diagnostic:
---------------------
IssuesNoWarnings failed.
--> The value must be an instance of the expected type.
    
    Actual Class:
        double
    Expected Type:
        function_handle

Actual Value:
         5

Verify that the constraint is not satisfied if the actual value results in a warning.

testCase.verifyThat(@() warning('some:id', 'Message'), IssuesNoWarnings)
Warning: Message 
> In @()warning('some:id','Message')
  In matlab.unittest.internal.constraints.FunctionHandleConstraint/invoke (line 36)
  In matlab.unittest.internal.constraints.WarningQualificationConstraint/invoke (line 39)
  In matlab.unittest.constraints.IssuesNoWarnings/issuesNoWarnings (line 140)
  In matlab.unittest.constraints.IssuesNoWarnings/satisfiedBy (line 90)
  In matlab.unittest.internal.qualifications.QualificationDelegate/qualifyThat (line 62)
  In matlab.unittest.qualifications.Verifiable/verifyThat (line 228) 
Interactive verification failed.

---------------------
Framework Diagnostic:
---------------------
IssuesNoWarnings failed.
--> The function issued warnings.
    
    Warnings Issued:
        --> 'some:id'
                Message

Evaluated Function:
        @()warning('some:id','Message')
Was this topic helpful?