verify
Assess logical expression and automatically log result
Description
verify(
evaluates a scalar logical
expression
)expression
to true
or
false
.
verify(
returns the specified error message for the failed expression
,errorMessage
)verify
statement. If
you run the test in the Test Manager, the error message appears in the simulation log. If
you run the test outside the Test Manager, the message appears in the Diagnostic Viewer. The
errorMessage
is a character array, which you can format using
sprintf
. You cannot, however use
sprintf
formatting in strings or character arrays in Stateflow® charts.
Note
In a real-time environment, verify
statement failures do not
produce warnings. However, if you run a real-time test case in the Test Manager, the
failures are shown in the Verify Statements section of the test
case results. You can also access information about the verify
runs
using getVerifyRuns
verify(
uses the expression
,identifier
,errorMessage
)identifier
as a label for the test results. The
identifier
is used as the signal label in the Test Manager. If you
run the test outside the Test Manager, the label appears in the Simulation Data Inspector
or, for a failure, in the Diagnostic Viewer. The identifier
is a
character array that has at least two colon-separated MATLAB® identifiers.
Examples
Limitations
You cannot use
verify
statements in:Test Sequence blocks that use continuous-time updating. Test Sequence block data can depend on factors such as the solver step time. Continuous-time updating can cause differences in when block data and
verify
statements update, which can lead to unexpectedverify
statement results. If your model uses continuous time and you useverify
statements in a Test Sequence or Test Assessment block, consider explicitly setting a discrete block sample time.Moore, Mealy, Discrete Event, or continuous charts
Charts that use C as the action language
Bind actions in a chart
Transition or condition actions in a chart
MATLAB functions, graphical functions, or truth tables in a chart
MATLAB Function or Truth Table blocks
Rapid Accelerator mode simulations
Code generation targets other than Simulink® Real-Time™ and HDL Verifier™
Standalone Stateflow charts
You cannot use
verify
as a condition immediately afterwhen
in a When decomposition becauseverify
statements do not produce output. You can, however, useverify
statements as actions inWhen
decomposition steps. See Verify Model Simulation by Using When Decomposition.
Tips
You can use
verify
statements in Test Sequence and Test Assessment blocks and in Stateflow charts. A Stateflow license is required to use a chart.verify
statements in charts are supported in the same locations, execution modes, and for the same code generation targets as the Test Sequence block.If you use parallel test execution to run your tests, then you cannot use the Highlight in Model button for in the Test Manager to
verify
results.When comparing floating-point data in
verify
statements, consider the precision limitations associated with floating-point numbers. If you need to use floating-point data, define a tolerance for the verification. For example, instead ofverify(x == 5)
, verifyx
within a tolerance of 0.001:For more information, see Floating-Point Numbers.verify(abs(x-5) < 0.001)
You can choose to log only
tested
verify
statement results to display onlypass
andfail
results in the Test Manager and Simulation Data Inspector, and reduce the transfer of data when you simulate a model on target hardware.To log only
pass
andfail
verify
results, on the Tests or Harness tab, in the Test Cases section, click Suppress Untested Results. Alternatively, you can useset_param
to set thelogOnlyTestedVerifyResults
parameter to'on'
. For example, to log onlytested
verify statement results for the modelmyModel
:When you select this option, the setting applies to all Test Sequence or Chart blocks in the model. The setting does not apply when using HDL Verifier.set_param(myModel,'logOnlyTestedVerifyResults','on')
Version History
Introduced in R2016a