From 0cb5824977dbff51fa7b77c20279b6bd4cb49d78 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sun, 18 Oct 2020 19:59:29 +0200 Subject: Implemented optimize() --- test-asm.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test-asm.cpp') diff --git a/test-asm.cpp b/test-asm.cpp index efdeab9..1d4634e 100644 --- a/test-asm.cpp +++ b/test-asm.cpp @@ -115,4 +115,18 @@ TEST_F(AsmTest, Intel64_multiple) { 0xE9, 0xFF, 0xFF, 0xFF, 0xFF, // jmp data1 0x01, 0x02, 0x03 // data })); + + segment.optimize(); + + ASSERT_EQ(segment.size(), 7); + ASSERT_EQ(segment.getCode(), std::vector( + { + 0x90, // nop + 0xCD, 0x05, // int 5 + 0xC3, // ret + // data1: + 0xC3, // ret + 0xEB, 0xFF, // jmp data1 + 0x01, 0x02, 0x03 // data + })); } -- cgit v1.2.3