Skip to content

Commit

Permalink
Add test for issue #129
Browse files Browse the repository at this point in the history
  • Loading branch information
ZehMatt committed Jun 8, 2024
1 parent a8f024e commit 5090a9f
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/src/tests/tests.serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1278,4 +1278,28 @@ namespace zasm::tests
"operand 1"));
}

TEST(SerializationTests, Issue_129)
{
int64_t rva = 0x3471fe;
int64_t jmp_rva = 0x347486;

Program program(zasm::MachineMode::AMD64);
x86::Assembler assembler(program);

assembler.jmp(zasm::Imm(jmp_rva));

zasm::Serializer serializer{};
ASSERT_EQ(serializer.serialize(program, rva), ErrorCode::None);

const std::array<uint8_t, 5> expected = { 0xe9, 0x83, 0x02, 0x00, 0x00 };
ASSERT_EQ(serializer.getCodeSize(), expected.size());

const auto* data = serializer.getCode();
ASSERT_NE(data, nullptr);
for (std::size_t i = 0; i < expected.size(); i++)
{
ASSERT_EQ(data[i], expected[i]);
}
}

} // namespace zasm::tests

0 comments on commit 5090a9f

Please sign in to comment.