summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorneeraj pratap singh <neerajpratapsingh@li-ff7f0d4c-3462-11b2-a85c-d4004c0fa1a0.ibm.com>2024-08-06 17:36:38 +0200
committerneeraj pratap singh <neerajpratapsingh@li-ff7f0d4c-3462-11b2-a85c-d4004c0fa1a0.ibm.com>2024-09-24 10:03:31 +0200
commit07d5199c9d8ccce18744760395517284b77f9205 (patch)
treed6bd11c2a2c88d4209e2603fc0a031e3ec68489d
parentsrc/common : proper handling of units in `strict_iec_cast` (diff)
downloadceph-07d5199c9d8ccce18744760395517284b77f9205.tar.xz
ceph-07d5199c9d8ccce18744760395517284b77f9205.zip
src/test: test to check proper handling of units by strict_iec_cast
Fixes: https://tracker.ceph.com/issues/67169 Signed-off-by: Neeraj Pratap Singh <neesingh@redhat.com>
-rw-r--r--src/test/strtol.cc27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/test/strtol.cc b/src/test/strtol.cc
index ec3f6715b8e..aac52c6627f 100644
--- a/src/test/strtol.cc
+++ b/src/test/strtol.cc
@@ -184,6 +184,18 @@ TEST(IECStrToLL, WithUnits) {
units["Ti"] = 40;
units["Pi"] = 50;
units["Ei"] = 60;
+ units["KB"] = 10;
+ units["MB"] = 20;
+ units["GB"] = 30;
+ units["TB"] = 40;
+ units["PB"] = 50;
+ units["EB"] = 60;
+ units["KiB"] = 10;
+ units["MiB"] = 20;
+ units["GiB"] = 30;
+ units["TiB"] = 40;
+ units["PiB"] = 50;
+ units["EiB"] = 60;
for (std::map<std::string,int>::iterator p = units.begin();
p != units.end(); ++p) {
@@ -259,6 +271,21 @@ TEST(StrictIECCast, Error) {
}
{
std::string err;
+ (void)strict_iec_cast<int64_t>("1GT", &err);
+ ASSERT_NE(err, "");
+ }
+ {
+ std::string err;
+ (void)strict_iec_cast<int64_t>("1TG", &err);
+ ASSERT_NE(err, "");
+ }
+ {
+ std::string err;
+ (void)strict_iec_cast<int64_t>("1KD", &err);
+ ASSERT_NE(err, "");
+ }
+ {
+ std::string err;
(void)strict_iec_cast<int64_t>("2E", &err);
ASSERT_EQ(err, "");
}