diff --git a/common/utils/UtilsTest.cpp b/common/utils/UtilsTest.cpp index e913b00bb49c13303757a3e0588a63c72f9b614f..e3f1f0b0c2db0def7395f95a59f1c3907c6f9581 100644 --- a/common/utils/UtilsTest.cpp +++ b/common/utils/UtilsTest.cpp @@ -484,34 +484,34 @@ TEST_F(cta_UtilsTest, toUint64_not_a_number) { ASSERT_THROW(utils::toUint64("one"), exception::Exception); } -TEST_F(cta_UtilsTest, isValidDouble) { +TEST_F(cta_UtilsTest, isValidDecimal) { using namespace cta; - ASSERT_TRUE(utils::isValidDouble("1.234")); + ASSERT_TRUE(utils::isValidDecimal("1.234")); } -TEST_F(cta_UtilsTest, isValidDouble_empty_string) { +TEST_F(cta_UtilsTest, isValidDecimal_empty_string) { using namespace cta; - ASSERT_FALSE(utils::isValidDouble("")); + ASSERT_FALSE(utils::isValidDecimal("")); } -TEST_F(cta_UtilsTest, isValidDouble_negative_double) { +TEST_F(cta_UtilsTest, isValidDecimal_negative_double) { using namespace cta; - ASSERT_TRUE(utils::isValidDouble("-1.234")); + ASSERT_TRUE(utils::isValidDecimal("-1.234")); } -TEST_F(cta_UtilsTest, isValidDouble_not_a_number) { +TEST_F(cta_UtilsTest, isValidDecimal_not_a_number) { using namespace cta; - ASSERT_FALSE(utils::isValidDouble("one")); + ASSERT_FALSE(utils::isValidDecimal("one")); } -TEST_F(cta_UtilsTest, isValidDouble_two_decimal_points) { +TEST_F(cta_UtilsTest, isValidDecimal_two_decimal_points) { using namespace cta; - ASSERT_FALSE(utils::isValidDouble("1.2.34")); + ASSERT_FALSE(utils::isValidDecimal("1.2.34")); } TEST_F(cta_UtilsTest, toDouble_double) { diff --git a/common/utils/utils.cpp b/common/utils/utils.cpp index 6d3bb155a4169d2efd7262517538cc47a45d66b7..ac4d0221b54919fcc6c2965ce87f42318a194d7c 100644 --- a/common/utils/utils.cpp +++ b/common/utils/utils.cpp @@ -639,10 +639,10 @@ uint64_t toUint64(const std::string &str) { } //------------------------------------------------------------------------------ -// isValidDouble +// isValidDecimal //------------------------------------------------------------------------------ -bool isValidDouble(const std::string &str) { - // An empty string is not a valid double +bool isValidDecimal(const std::string &str) { + // An empty string is not a valid decimal if(str.empty()) { return false; } diff --git a/common/utils/utils.hpp b/common/utils/utils.hpp index 3ac5b6275e1e91d68d1b70d00beb15f4a88bb333..d56e933011cd61dced8dd996b878c369a50cba36 100644 --- a/common/utils/utils.hpp +++ b/common/utils/utils.hpp @@ -281,12 +281,12 @@ namespace utils { uint64_t toUint64(const std::string &str); /** - * Checks if the specified string is a double unsigned integer. + * Checks if the specified string is a valid decimal. * * @param str The string to be checked. - * @returns true if the string is a valid double, else false. + * @returns true if the string is a valid decimal, else false. */ - bool isValidDouble(const std::string &str); + bool isValidDecimal(const std::string &str); /** * Parses the specified string representation of a double. diff --git a/rdbms/wrapper/PostgresRset.cpp b/rdbms/wrapper/PostgresRset.cpp index 146db002497f8994c8678dc17603a41a8e038621..8ade84da2175cf0c3d74b9080fbaaaa04b32db90 100644 --- a/rdbms/wrapper/PostgresRset.cpp +++ b/rdbms/wrapper/PostgresRset.cpp @@ -144,9 +144,9 @@ optional<double> PostgresRset::columnOptionalDouble(const std::string &colName) const std::string stringValue(PQgetvalue(m_resItr->get(), 0, ifield)); - if(!utils::isValidDouble(stringValue)) { + if(!utils::isValidDecimal(stringValue)) { throw exception::Exception(std::string("Column ") + colName + " contains the value " + stringValue + - " which is not a valid double"); + " which is not a valid decimal"); } return utils::toDouble(stringValue);