Skip to content

Commit e5d7e7e

Browse files
yperbasischfast
authored andcommitted
Make Result : evmc_result inheritance public
This allows accessing evmc::Result via reference to evmc_result.
1 parent 44fc118 commit e5d7e7e

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

include/evmc/evmc.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ constexpr auto make_result = evmc_make_result;
328328
///
329329
/// This is a RAII wrapper for evmc_result and objects of this type
330330
/// automatically release attached resources.
331-
class Result : private evmc_result
331+
class Result : public evmc_result
332332
{
333333
public:
334334
using evmc_result::create_address;

test/unittests/cpp_test.cpp

+23
Original file line numberDiff line numberDiff line change
@@ -973,3 +973,26 @@ TEST(cpp, revision_to_string_invalid)
973973
EXPECT_EQ(os.str(), "<unknown>");
974974
}
975975
}
976+
977+
TEST(cpp, result_c_const_access)
978+
{
979+
static constexpr auto get_gas_left = [](const evmc_result& c_result) noexcept{
980+
return c_result.gas_left;
981+
};
982+
983+
evmc::Result r;
984+
r.gas_left = 1;
985+
EXPECT_EQ(get_gas_left(r), 1);
986+
}
987+
988+
TEST(cpp, result_c_nonconst_access)
989+
{
990+
static constexpr auto reset_gas_left = [](evmc_result& c_result) noexcept{
991+
c_result.gas_left = 0;
992+
};
993+
994+
evmc::Result r;
995+
r.gas_left = 1;
996+
reset_gas_left(r);
997+
EXPECT_EQ(r.gas_left, 0);
998+
}

0 commit comments

Comments
 (0)