Skip to content

Commit 727c180

Browse files
hugo-dcgumb0
andcommitted
Avoid using std::format
Co-authored-by: Andrei Maiboroda <[email protected]>
1 parent 314b6ab commit 727c180

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

test/unittests/eof_test.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include <gtest/gtest.h>
77
#include <test/utils/bytecode.hpp>
88
#include <test/utils/utils.hpp>
9-
#include <format>
109

1110
using namespace std;
1211
using namespace evmone;
@@ -48,7 +47,7 @@ TEST(eof, read_valid_eof1_header)
4847
if (i < 255)
4948
{
5049
nops_255 += "5B";
51-
code_sections_256 += "E5" + std::format("{:04X}", i + 1);
50+
code_sections_256 += "E5" + hex(big_endian(static_cast<uint16_t>(i + 1)));
5251
}
5352
else
5453
code_sections_256 += "5B5B00";

test/unittests/eof_validation_test.cpp

+13-10
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include <gtest/gtest.h>
88
#include <test/utils/bytecode.hpp>
99
#include <test/utils/utils.hpp>
10-
#include <format>
1110

1211
using namespace std;
1312
using namespace evmone;
@@ -316,7 +315,7 @@ TEST(eof_validation, EOF1_too_many_code_sections)
316315
std::string code_sections_1024;
317316
for (int i = 0; i < 1024; ++i)
318317
if (i < 1023)
319-
code_sections_1024 += "E5" + std::format("{:04X}", i + 1);
318+
code_sections_1024 += "E5" + hex(big_endian(static_cast<uint16_t>(i + 1)));
320319
else
321320
code_sections_1024 += "5B5B00";
322321

@@ -867,7 +866,7 @@ TEST(eof_validation, many_code_sections_1023)
867866
std::string code_sections_1023;
868867
for (auto i = 0; i < 1023; ++i)
869868
if (i < 1022)
870-
code_sections_1023 += "E5" + std::format("{:04X}", i + 1);
869+
code_sections_1023 += "E5" + hex(big_endian(static_cast<uint16_t>(i + 1)));
871870
else
872871
code_sections_1023 += "5B5B00";
873872

@@ -882,7 +881,7 @@ TEST(eof_validation, many_code_sections_1024)
882881
std::string code_sections_1024;
883882
for (auto i = 0; i < 1024; ++i)
884883
if (i < 1023)
885-
code_sections_1024 += "E5" + std::format("{:04X}", i + 1);
884+
code_sections_1024 += "E5" + hex(big_endian(static_cast<uint16_t>(i + 1)));
886885
else
887886
code_sections_1024 += "5B5B00";
888887

@@ -1251,18 +1250,22 @@ TEST(eof_validation, unreachable_code_sections)
12511250
if (i < 255)
12521251
if (i == 1)
12531252
{
1254-
code_sections_256_err_001 += "E5" + std::format("{:04X}", i);
1255-
code_sections_256_err_254 += "E5" + std::format("{:04X}", i + 1);
1253+
code_sections_256_err_001 += "E5" + hex(big_endian(static_cast<uint16_t>(i)));
1254+
code_sections_256_err_254 +=
1255+
"E5" + hex(big_endian(static_cast<uint16_t>(i + 1)));
12561256
}
12571257
else if (i == 254)
12581258
{
1259-
code_sections_256_err_001 += "E5" + std::format("{:04X}", i + 1);
1260-
code_sections_256_err_254 += "E5" + std::format("{:04X}", i);
1259+
code_sections_256_err_001 +=
1260+
"E5" + hex(big_endian(static_cast<uint16_t>(i + 1)));
1261+
code_sections_256_err_254 += "E5" + hex(big_endian(static_cast<uint16_t>(i)));
12611262
}
12621263
else
12631264
{
1264-
code_sections_256_err_001 += "E5" + std::format("{:04X}", i + 1);
1265-
code_sections_256_err_254 += "E5" + std::format("{:04X}", i + 1);
1265+
code_sections_256_err_001 +=
1266+
"E5" + hex(big_endian(static_cast<uint16_t>(i + 1)));
1267+
code_sections_256_err_254 +=
1268+
"E5" + hex(big_endian(static_cast<uint16_t>(i + 1)));
12661269
}
12671270
else
12681271
{

0 commit comments

Comments
 (0)