Merge pull request #6924 from Icinga/bugfix/convert-long-double

Fix double to long conversions
This commit is contained in:
Michael Friedrich 2019-01-30 15:18:12 +01:00 committed by GitHub
commit b334c3259e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View File

@ -64,6 +64,11 @@ public:
return val;
}
static long ToLong(double val)
{
return static_cast<long>(val);
}
static double ToDouble(const Value& val)
{
return val;

View File

@ -33,6 +33,8 @@ BOOST_AUTO_TEST_CASE(tolong)
BOOST_CHECK_THROW(Convert::ToLong("7a"), boost::exception);
BOOST_CHECK(Convert::ToLong(Value(-7)) == -7);
BOOST_CHECK(Convert::ToLong(3.141386593) == 3);
}
BOOST_AUTO_TEST_CASE(todouble)