mirror of
https://github.com/sampletext32/ParkanPlayground.git
synced 2025-06-20 00:18:02 +03:00
Added comprehensive tests for various instruction handlers. Created test files for Jump, Return, XOR, Group1, Group3, and Call instructions. Fixed ConditionalJumpHandler test to use 'jz' instead of 'je' since they are equivalent in x86.
This commit is contained in:
32
X86DisassemblerTests/CallInstructionTests.cs
Normal file
32
X86DisassemblerTests/CallInstructionTests.cs
Normal file
@ -0,0 +1,32 @@
|
||||
namespace X86DisassemblerTests;
|
||||
|
||||
using System;
|
||||
using Xunit;
|
||||
using X86Disassembler.X86;
|
||||
using X86Disassembler.X86.Handlers;
|
||||
|
||||
/// <summary>
|
||||
/// Tests for call instruction handlers
|
||||
/// </summary>
|
||||
public class CallInstructionTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Tests the CallRel32Handler for decoding CALL rel32 instruction
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void CallRel32Handler_DecodesCallRel32_Correctly()
|
||||
{
|
||||
// Arrange
|
||||
// CALL +0x12345678 (E8 78 56 34 12) - Call to address 0x12345678 bytes forward
|
||||
byte[] codeBuffer = new byte[] { 0xE8, 0x78, 0x56, 0x34, 0x12 };
|
||||
var decoder = new InstructionDecoder(codeBuffer, codeBuffer.Length);
|
||||
|
||||
// Act
|
||||
var instruction = decoder.DecodeInstruction();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(instruction);
|
||||
Assert.Equal("call", instruction.Mnemonic);
|
||||
Assert.Equal("0x1234567D", instruction.Operands); // Current position (5) + offset (0x12345678) = 0x1234567D
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user