]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
test: avoid converting addresses to "long"
authorLucian Petrut <lpetrut@cloudbasesolutions.com>
Tue, 11 Apr 2023 09:40:12 +0000 (09:40 +0000)
committerLucian Petrut <lpetrut@cloudbasesolutions.com>
Thu, 17 Aug 2023 13:31:51 +0000 (13:31 +0000)
On Windows x64 hosts, "long" (4B) is not large enough to hold
an address.

For this reason, we're updating "test_json_formattable.cc"
to use "long long" instead.

Signed-off-by: Lucian Petrut <lpetrut@cloudbasesolutions.com>
src/test/common/test_json_formattable.cc

index 62448e8080b586ba7dbc5b7ed96d35577b652a9a..013736f0ec884488f476b57fff03d753bc832266 100644 (file)
@@ -336,13 +336,13 @@ TEST(formatable, encode_simple) {
 
 
 struct struct1 {
-  long i;
+  long long i;
   string s;
   bool b;
 
   struct1() {
     void *p = (void *)this;
-    i = (long)p;
+    i = (long long)p;
     char buf[32];
     snprintf(buf, sizeof(buf), "%p", p);
     s = buf;
@@ -363,12 +363,12 @@ struct struct1 {
 
   bool compare(const JSONFormattable& jf) const {
     bool ret = (s == (string)jf["s"] &&
-            i == (long)jf["i"] &&
+            i == (long long)jf["i"] &&
             b == (bool)jf["b"]);
 
     if (!ret) {
       cout << "failed comparison: s=" << s << " jf[s]=" << (string)jf["s"] << 
-        " i=" << i << " jf[i]=" << (long)jf["i"] << " b=" << b << " jf[b]=" << (bool)jf["b"] << std::endl;
+        " i=" << i << " jf[i]=" << (long long)jf["i"] << " b=" << b << " jf[b]=" << (bool)jf["b"] << std::endl;
       dumpf(jf);
     }
 
@@ -383,7 +383,7 @@ struct struct2 {
 
   struct2() {
     void *p = (void *)this;
-    long i = (long)p;
+    long long i = (long long)p;
     v.resize((i >> 16) % 16 + 1);
   }