<< assert_checkerror | Assertion functions | assert_isequal >> |
assert_isapprox(computed, expected) |
assert_isapprox(computed, expected, precision) |
res = assert_isapprox(computed, expected, precision) |
[res, msg] = assert_isapprox(computed, expected, precision) |
a value: numeric matrix, sparse double, a multidimensional matrix
a value: numeric matrix, sparse double, a multidimensional matrix
a double value. default precision is 0.
a logical value
a string value, the error message. If res == true, then errormsg == ''. If res == false, then msg contains the error message.
assert_isapprox raises an error if computed value is not approximately equal to expected value.
This function compares two floating point numbers, which allows to check that two numbers are "approximately" equal, i.e. that the relative error is small.
assert_isapprox(1.23456, 1.23457, 1e-5)
assert_isapprox(1.23456, 1.23457, 1e-6)
[r, msg] =assert_isapprox(1.23456, 1.23457, 1e-6)
assert_isfalse(r);
assert_isequal(msg, _('Assertion failed: expected and computed values are too different.'));
Version | Description |
---|---|
1.0.0 | initial version |
Allan CORNET