From: Vikhyat Umrao Date: Thu, 26 May 2016 18:00:25 +0000 (+0530) Subject: common: add int64_t template for strict_si_cast() X-Git-Tag: v10.2.4~76^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d93eda88048d2bcefe4be3ea0aaa6ca0289eabbf;p=ceph.git common: add int64_t template for strict_si_cast() Signed-off-by: Vikhyat Umrao (cherry picked from commit 8e429d05370fbe7935212d0ae9608e7547f39860) --- diff --git a/src/common/strtol.cc b/src/common/strtol.cc index bc5ccc74cb11..0e7ea7d30114 100644 --- a/src/common/strtol.cc +++ b/src/common/strtol.cc @@ -187,6 +187,7 @@ T strict_si_cast(const char *str, std::string *err) template int strict_si_cast(const char *str, std::string *err); template long long strict_si_cast(const char *str, std::string *err); +template int64_t strict_si_cast(const char *str, std::string *err); template uint64_t strict_si_cast(const char *str, std::string *err); template uint32_t strict_si_cast(const char *str, std::string *err); diff --git a/src/test/strtol.cc b/src/test/strtol.cc index 646c055fb5d8..3946736b9157 100644 --- a/src/test/strtol.cc +++ b/src/test/strtol.cc @@ -234,6 +234,21 @@ TEST(StrictSICast, Error) { (void)strict_si_cast("1T", &err); ASSERT_NE(err, ""); } + { + std::string err; + (void)strict_si_cast("2E", &err); + ASSERT_EQ(err, ""); + } + { + std::string err; + (void)strict_si_cast("-2E", &err); + ASSERT_EQ(err, ""); + } + { + std::string err; + (void)strict_si_cast("1T", &err); + ASSERT_EQ(err, ""); + } } /*