]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common: add int64_t template for strict_si_cast() 9297/head
authorVikhyat Umrao <vumrao@redhat.com>
Thu, 26 May 2016 18:00:25 +0000 (23:30 +0530)
committerVikhyat Umrao <vumrao@redhat.com>
Thu, 26 May 2016 18:38:08 +0000 (00:08 +0530)
Signed-off-by: Vikhyat Umrao <vumrao@redhat.com>
src/common/strtol.cc
src/test/strtol.cc

index bc5ccc74cb115a019af350eb2837b11205ffa95b..0e7ea7d3011476cb2c39855b7d188af07cceb33d 100644 (file)
@@ -187,6 +187,7 @@ T strict_si_cast(const char *str, std::string *err)
 
 template int strict_si_cast<int>(const char *str, std::string *err);
 template long long strict_si_cast<long long>(const char *str, std::string *err);
+template int64_t strict_si_cast<int64_t>(const char *str, std::string *err);
 template uint64_t strict_si_cast<uint64_t>(const char *str, std::string *err);
 template uint32_t strict_si_cast<uint32_t>(const char *str, std::string *err);
 
index 646c055fb5d89daae2817779e7e35f95d890751d..3946736b915725f4dcb8ee4276e32cb1d7c9a0b4 100644 (file)
@@ -234,6 +234,21 @@ TEST(StrictSICast, Error) {
     (void)strict_si_cast<int>("1T", &err);
     ASSERT_NE(err, "");
   }
+  {
+    std::string err;
+    (void)strict_si_cast<int64_t>("2E", &err);
+    ASSERT_EQ(err, "");
+  }
+  {
+    std::string err;
+    (void)strict_si_cast<int64_t>("-2E", &err);
+    ASSERT_EQ(err, "");
+  }
+  {
+    std::string err;
+    (void)strict_si_cast<int64_t>("1T", &err);
+    ASSERT_EQ(err, "");
+  }
 }
 
 /*