matlab.unittest.qualifications.Verifiable.verifyEmpty - Verify value is empty - MATLAB (original) (raw)

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

Syntax

Description

verifyEmpty([testCase](#bt00p20-1%5Fsep%5Fmw%5F8d5e73c7-bacb-46a7-a1c1-f24af91e6c03),[actual](#mw%5Fda7de1de-c6e7-4042-8426-83b6c0b2468b)) verifies that actual is an empty MATLAB® array.

example

verifyEmpty([testCase](#bt00p20-1%5Fsep%5Fmw%5F8d5e73c7-bacb-46a7-a1c1-f24af91e6c03),[actual](#mw%5Fda7de1de-c6e7-4042-8426-83b6c0b2468b),[diagnostic](#mw%5F4873e8a3-4f0f-4cc0-83d4-1f46354e05d8)) 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.

Value to test, specified as an array of any data type.

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;

Test an empty character vector. The test passes.

Create a test case for interactive testing.

testCase = matlab.unittest.TestCase.forInteractiveUse;

Verify that an array with a zero dimension is empty.

verifyEmpty(testCase,ones(2,5,0,3))

Test if the vector [2 3] is empty. The test fails.

verifyEmpty(testCase,[2 3],"Value must be empty.")

Verification failed. ---------------- Test Diagnostic: ---------------- Value must be empty. --------------------- Framework Diagnostic: --------------------- verifyEmpty failed. --> The value must be empty. --> The value has a size of [1 2].

Actual Value:
     2     3
------------------
Stack Information:
------------------
In C:\work\TestForEmptyArraysExample.m (TestForEmptyArraysExample) at 10

Create a test case for interactive testing.

testCase = matlab.unittest.TestCase.forInteractiveUse;

Test an empty cell array. The test passes.

Test a cell array of empty numeric arrays. The test fails.

verifyEmpty(testCase,{[],[],[]})

Verification failed. --------------------- Framework Diagnostic: --------------------- verifyEmpty failed. --> The value must be empty. --> The value has a size of [1 3].

Actual Value:
  1×3 cell array

    {0×0 double}    {0×0 double}    {0×0 double}
------------------
Stack Information:
------------------
In C:\work\TestForEmptyCellArraysExample.m (TestForEmptyCellArraysExample) at 10

Create a test case for interactive testing.

testCase = matlab.unittest.TestCase.forInteractiveUse;

Create and test an empty test suite. The test passes.

emptyTestSuite = matlab.unittest.TestSuite.empty; verifyEmpty(testCase,emptyTestSuite)

Tips

Version History

Introduced in R2013a