matlab.unittest.qualifications.Verifiable.verifyNotEqual - Verify value is not equal to specified value - MATLAB (original) (raw)

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

Verify value is not equal to specified value

Syntax

Description

verifyNotEqual([testCase](#bt00q2%5F-1%5Fsep%5Fmw%5F8d5e73c7-bacb-46a7-a1c1-f24af91e6c03),[actual](#mw%5F68a38697-0ada-40ef-bf42-6a941e3f402b),[prohibited](#mw%5Fee19101b-c5c4-4b7b-b4ba-4c891511cd4d)) verifies that actual is not equal to prohibited.

example

verifyNotEqual([testCase](#bt00q2%5F-1%5Fsep%5Fmw%5F8d5e73c7-bacb-46a7-a1c1-f24af91e6c03),[actual](#mw%5F68a38697-0ada-40ef-bf42-6a941e3f402b),[prohibited](#mw%5Fee19101b-c5c4-4b7b-b4ba-4c891511cd4d),[diagnostic](#mw%5Fd1601ba8-def3-4d5c-8d41-7e9eecfc4491)) 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 a value of any data type.

Value to compare against, specified as a value 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;

Compare a numeric value to itself. The test fails.

verifyNotEqual(testCase,5,5,"Values must be different.")

Verification failed. ---------------- Test Diagnostic: ---------------- Values must be different. --------------------- Framework Diagnostic: --------------------- verifyNotEqual failed. --> The numeric values are equal using "isequaln".

Actual Value:
     5
Prohibited Value:
     5
------------------
Stack Information:
------------------
In C:\work\CompareNumericValuesExample.m (CompareNumericValuesExample) at 12

Verify that different numeric scalars are not equal.

verifyNotEqual(testCase,4.95,5)

Verify that values of different sizes are not equal.

verifyNotEqual(testCase,[5 5],5)

Create a test case for interactive testing.

testCase = matlab.unittest.TestCase.forInteractiveUse;

Compare two numeric values of different classes. The test passes.

verifyNotEqual(testCase,int8(5),int16(5))

Create a test case for interactive testing.

testCase = matlab.unittest.TestCase.forInteractiveUse;

Test if two cell arrays are not equal.

verifyNotEqual(testCase,{'cell',struct,5},{'cell',struct,4.95})

Tips

Version History

Introduced in R2013a

expand all

You can use the verifyNotEqual method to compare MATLABĀ® dictionaries.

The verifyNotEqual method now consistently compares the size and type of table variables. For example, this test passes because the actual and expected table variables have different types.

testCase = matlab.unittest.TestCase.forInteractiveUse; act = table(zeros(0,2)); exp = table({}); testCase.verifyNotEqual(act,exp)

In previous releases, the test fails because the method does not compare the table variables when the tables have no rows.