Skip to content

Commit

Permalink
fix(tests/instruction): tests for x86
Browse files Browse the repository at this point in the history
  • Loading branch information
Curve committed May 9, 2024
1 parent 77767a2 commit ed43672
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions tests/instruction.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ std::vector<unsigned char> code = {

suite<"Instruction"> instruction_suite = []
{
static constexpr auto is64bit = sizeof(std::uintptr_t) == 8;

static constexpr auto MNEMONIC_MOV = 436;
static constexpr auto MNEMONIC_JMP = 311;

Expand Down Expand Up @@ -60,7 +62,7 @@ suite<"Instruction"> instruction_suite = []

expect(eq(rel_move.has_value(), true));

expect(eq(rel_move->relative(), true));
expect(eq(rel_move->relative(), is64bit));
expect(eq(rel_move->branching(), false));
expect(eq(rel_move->mnemonic(), MNEMONIC_MOV));

Expand All @@ -72,7 +74,7 @@ suite<"Instruction"> instruction_suite = []

expect(eq(jmp->addr(), jmp_until->addr()));

expect(eq(jmp->relative(), true));
expect(eq(jmp->relative(), is64bit));
expect(eq(jmp->branching(), true));
expect(eq(jmp->mnemonic(), MNEMONIC_JMP));

Expand All @@ -84,17 +86,15 @@ suite<"Instruction"> instruction_suite = []
expect(eq(abs_jmp->branching(), true));
expect(eq(abs_jmp->mnemonic(), MNEMONIC_JMP));

#if INTPTR_MAX == INT64_MAX
expect(eq(next->size(), 3));
expect(eq(next->addr(), reinterpret_cast<std::uintptr_t>(data) + 0x2));

expect(eq(rel_move->size(), 7));
expect(eq(rel_move->addr(), reinterpret_cast<std::uintptr_t>(data) + 15));

expect(eq(jmp->size(), 6));
expect(eq(abs_jmp->addr(), jmp->addr() + jmp->size()));
expect(eq(rel_move->addr(), mov->addr() + mov->size()));
expect(eq(jmp->addr(), rel_move->addr() + rel_move->size()));
expect(eq(mov->addr(), instruction->addr() + instruction->size()));

#if INTPTR_MAX == INT64_MAX
expect(eq(mov->size(), 3));
expect(eq(jmp->size(), 6));
expect(eq(abs_jmp->size(), 2));
expect(eq(abs_jmp->addr(), jmp->addr() + jmp->size()));
expect(eq(rel_move->size(), 7));
#endif
};

0 comments on commit ed43672

Please sign in to comment.