Fix failing unit tests

refs #8043
This commit is contained in:
Gunnar Beutner 2014-12-10 11:25:20 +01:00
parent c381e15b5a
commit d88856a994
3 changed files with 8 additions and 8 deletions

View File

@ -22,11 +22,6 @@
using namespace icinga;
bool Convert::ToBool(const String& val)
{
return (ToLong(val) != 0);
}
String Convert::ToString(const String& val)
{
return val;

View File

@ -64,7 +64,10 @@ public:
return val;
}
static bool ToBool(const String& val);
static inline bool ToBool(const Value& val)
{
return val.ToBool();
}
template<typename T>
static String ToString(const T& val)

View File

@ -60,10 +60,12 @@ BOOST_AUTO_TEST_CASE(tostring)
BOOST_AUTO_TEST_CASE(tobool)
{
BOOST_CHECK_THROW(Convert::ToBool("a"), boost::exception);
BOOST_CHECK(Convert::ToBool("0") == false);
BOOST_CHECK(Convert::ToBool("a") == true);
BOOST_CHECK(Convert::ToBool("0") == true);
BOOST_CHECK(Convert::ToBool("1") == true);
BOOST_CHECK(Convert::ToBool("2") == true);
BOOST_CHECK(Convert::ToBool(1) == true);
BOOST_CHECK(Convert::ToBool(0) == false);
BOOST_CHECK(Convert::ToBool(Value(true)) == true);
BOOST_CHECK(Convert::ToBool(Value(false)) == false);
}