0
mirror of https://github.com/sampletext32/ParkanPlayground.git synced 2025-06-19 16:08:02 +03:00

move tests to csv

This commit is contained in:
bird_egop
2025-04-13 17:02:46 +03:00
parent 565158d9bd
commit 2cdd9f1e83
12 changed files with 274 additions and 518 deletions

View File

@ -69,13 +69,13 @@ public class SubInstructionTests
}
/// <summary>
/// Tests the SubImmFromRm32SignExtendedHandler for decoding SUB r/m32, negative imm8 instruction (sign-extended)
/// Tests the SubImmFromRm32SignExtendedHandler for decoding SUB r/m32, imm8 instruction with negative value
/// </summary>
[Fact]
public void SubImmFromRm32SignExtendedHandler_DecodesSubRm32NegativeImm8_Correctly()
{
// Arrange
// SUB EAX, 0xF0 (83 E8 F0) - Subtract sign-extended 0xF0 from EAX
// SUB EAX, -0x10 (83 E8 F0) - Subtract sign-extended -0x10 from EAX
byte[] codeBuffer = new byte[] { 0x83, 0xE8, 0xF0 };
var decoder = new InstructionDecoder(codeBuffer, codeBuffer.Length);
@ -111,23 +111,25 @@ public class SubInstructionTests
}
/// <summary>
/// Tests the SubR32Rm32Handler for decoding SUB r32, r/m32 instruction
/// Tests a sequence of SUB instructions in a common pattern
/// </summary>
[Fact]
public void SubR32Rm32Handler_DecodesSubR32Rm32_Correctly()
public void SubInstruction_DecodesSubSequence_Correctly()
{
// Arrange
// SUB EBX, EAX (2B D8) - Subtract EAX from EBX
byte[] codeBuffer = new byte[] { 0x2B, 0xD8 };
var decoder = new InstructionDecoder(codeBuffer, codeBuffer.Length);
// SUB ESP, 0x10 (83 EC 10) - Create stack space
byte[] codeBuffer = new byte[] { 0x83, 0xEC, 0x10 };
var disassembler = new Disassembler(codeBuffer, 0);
// Act
var instruction = decoder.DecodeInstruction();
var instructions = disassembler.Disassemble();
// Assert
Assert.NotNull(instruction);
Assert.Equal("sub", instruction.Mnemonic);
Assert.Equal("ebx, eax", instruction.Operands);
Assert.Single(instructions);
// Instruction: SUB ESP, 0x10
Assert.Equal("sub", instructions[0].Mnemonic);
Assert.Equal("esp, 0x10", instructions[0].Operands);
}
/// <summary>
@ -170,6 +172,26 @@ public class SubInstructionTests
Assert.Equal("dword ptr [ebx+0x10], ecx", instruction.Operands);
}
/// <summary>
/// Tests the SubR32Rm32Handler for decoding SUB r32, r/m32 instruction
/// </summary>
[Fact]
public void SubR32Rm32Handler_DecodesSubR32Rm32_Correctly()
{
// Arrange
// SUB EBX, EAX (2B D8) - Subtract EAX from EBX
byte[] codeBuffer = new byte[] { 0x2B, 0xD8 };
var decoder = new InstructionDecoder(codeBuffer, codeBuffer.Length);
// Act
var instruction = decoder.DecodeInstruction();
// Assert
Assert.NotNull(instruction);
Assert.Equal("sub", instruction.Mnemonic);
Assert.Equal("ebx, eax", instruction.Operands);
}
/// <summary>
/// Tests the SubR32Rm32Handler for decoding SUB r32, memory instruction
/// </summary>