MathLib: Added robustness tests for 'MathLib::divide()'.

This commit is contained in:
orbitcowboy 2019-05-25 23:06:50 +02:00
parent 8f2a84ec6c
commit 4d223a70dc
1 changed files with 7 additions and 2 deletions

View File

@ -145,10 +145,15 @@ private:
ASSERT_EQUALS("5.0", MathLib::divide("25.5", "5.1"));
ASSERT_EQUALS("7.0", MathLib::divide("21.", "3"));
ASSERT_EQUALS("1", MathLib::divide("3", "2"));
ASSERT_THROW(MathLib::divide("123", "0"), InternalError); // throw
ASSERT_THROW(MathLib::divide("123", "0"), InternalError); // decimal zero: throw
ASSERT_THROW(MathLib::divide("123", "00"), InternalError); // octal zero: throw
ASSERT_THROW(MathLib::divide("123", "0x0"), InternalError); // hex zero: throw
MathLib::divide("123", "0.0f"); // float zero: don't throw
MathLib::divide("123", "0.0"); // double zero: don't throw
MathLib::divide("123", "0.0L"); // long double zero: don't throw
ASSERT_THROW(MathLib::divide("-9223372036854775808", "-1"), InternalError); // #4520 - out of range => throw
ASSERT_EQUALS("4611686018427387904", MathLib::divide("-9223372036854775808", "-2")); // #6679
MathLib::divide("123", "0.0"); // don't throw
// Unknown action should throw exception
ASSERT_THROW(MathLib::calculate("1","2",'j'),InternalError);