assert_isfalse(x)
r = assert_isfalse(x)
[r, msg] = assert_isfalse(x)
assert_isfalse(x, err_msg)
r = assert_isfalse(x, err_msg)
[r, msg] = assert_isfalse(x, err_msg)
| Parameter | Description |
|---|---|
| x | a logical value to be tested for falseness. |
| err_msg | a string containing the custom error message to display in case of assertion failure (optional). |
| Parameter | Description |
|---|---|
| r | a logical value: true if the assertion passes, false otherwise. |
| msg | a string containing the error message. If x == false, then msg == ''. If x == true, then msg contains the assertion failure message. |
assert_isfalse raises an error if the input value is true.
This function also raises an error if the input is not a logical value, ensuring type safety.
When the optional err_msg parameter is provided, it will be used as the error message instead of the default message when the assertion fails.
This function is useful in unit testing to verify that conditions are false or that logical operations return the expected false result.
assert_isfalse(3 ~= 4)
assert_isfalse(3 == 4)
r = assert_isfalse(false)
[r, msg] = assert_isfalse(false)
[r, msg] = assert_isfalse(3 == 3, 'your error message.');
if ~r
disp(['Custom error: ' msg])
end
try
assert_isfalse(true, 'This should be false!');
catch ME
disp(['Error caught: ' ME.message])
end
| Version | Description |
|---|---|
| 1.0.0 | initial version |