mirror of
https://github.com/sampletext32/ParkanPlayground.git
synced 2025-06-20 00:18:02 +03:00
unbreak tests
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
using X86Disassembler.X86;
|
||||
using X86Disassembler.X86.Operands;
|
||||
|
||||
namespace X86DisassemblerTests.InstructionTests;
|
||||
|
||||
@ -16,15 +17,19 @@ public class ReturnInstructionTests
|
||||
// Arrange
|
||||
// RET (C3) - Return from procedure
|
||||
byte[] codeBuffer = new byte[] { 0xC3 };
|
||||
var decoder = new InstructionDecoder(codeBuffer, codeBuffer.Length);
|
||||
var disassembler = new Disassembler(codeBuffer, 0);
|
||||
|
||||
// Act
|
||||
var instruction = decoder.DecodeInstruction();
|
||||
var instructions = disassembler.Disassemble();
|
||||
|
||||
// Assert
|
||||
Assert.Single(instructions);
|
||||
var instruction = instructions[0];
|
||||
Assert.NotNull(instruction);
|
||||
Assert.Equal("ret", instruction.Mnemonic);
|
||||
Assert.Equal("", instruction.Operands);
|
||||
Assert.Equal(InstructionType.Ret, instruction.Type);
|
||||
|
||||
// Check that we have no operands
|
||||
Assert.Empty(instruction.StructuredOperands);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -36,14 +41,25 @@ public class ReturnInstructionTests
|
||||
// Arrange
|
||||
// RET 0x1234 (C2 34 12) - Return from procedure and pop 0x1234 bytes
|
||||
byte[] codeBuffer = new byte[] { 0xC2, 0x34, 0x12 };
|
||||
var decoder = new InstructionDecoder(codeBuffer, codeBuffer.Length);
|
||||
var disassembler = new Disassembler(codeBuffer, 0);
|
||||
|
||||
// Act
|
||||
var instruction = decoder.DecodeInstruction();
|
||||
var instructions = disassembler.Disassemble();
|
||||
|
||||
// Assert
|
||||
Assert.Single(instructions);
|
||||
var instruction = instructions[0];
|
||||
Assert.NotNull(instruction);
|
||||
Assert.Equal("ret", instruction.Mnemonic);
|
||||
Assert.Equal("0x1234", instruction.Operands);
|
||||
Assert.Equal(InstructionType.Ret, instruction.Type);
|
||||
|
||||
// Check that we have one operand
|
||||
Assert.Single(instruction.StructuredOperands);
|
||||
|
||||
// Check the operand (immediate value)
|
||||
var immOperand = instruction.StructuredOperands[0];
|
||||
Assert.IsType<ImmediateOperand>(immOperand);
|
||||
var immediateOperand = (ImmediateOperand)immOperand;
|
||||
Assert.Equal(0x1234U, immediateOperand.Value);
|
||||
Assert.Equal(16, immediateOperand.Size); // Validate that it's a 16-bit immediate
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user