Documentation Center

  • Trial Software
  • Product Updates

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 FunctionHandleConstraint>FunctionHandleConstraint.invoke at 39
  In WarningQualificationConstraint>WarningQualificationConstraint.invoke at 54
  In IssuesNoWarnings>IssuesNoWarnings.issuesNoWarnings at 132
  In IssuesNoWarnings>IssuesNoWarnings.satisfiedBy at 83
  In QualificationDelegate>QualificationDelegate.qualifyThat at 58
  In Verifiable>Verifiable.verifyThat at 228 
Interactive verification failed.

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

Evaluated Function:
        @()warning('some:id','Message')

See Also

| | |

Was this topic helpful?