From 5090a9f13161815f7464b4b9aa8a4295bcaa5155 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Sat, 8 Jun 2024 20:14:30 +0300 Subject: [PATCH] Add test for issue #129 --- tests/src/tests/tests.serialization.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/src/tests/tests.serialization.cpp b/tests/src/tests/tests.serialization.cpp index 73dfd38..7c0cb05 100644 --- a/tests/src/tests/tests.serialization.cpp +++ b/tests/src/tests/tests.serialization.cpp @@ -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 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