From ba3c6d76a78c3f675984e79dd630b532dfade75e Mon Sep 17 00:00:00 2001 From: Lucian Petrut Date: Tue, 11 Apr 2023 09:40:12 +0000 Subject: [PATCH] test: avoid converting addresses to "long" 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 --- src/test/common/test_json_formattable.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/test/common/test_json_formattable.cc b/src/test/common/test_json_formattable.cc index 62448e8080b..013736f0ec8 100644 --- a/src/test/common/test_json_formattable.cc +++ b/src/test/common/test_json_formattable.cc @@ -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); } -- 2.39.5