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

Test fixes

This commit is contained in:
bird_egop
2025-04-16 18:30:17 +03:00
parent d4eb920e2f
commit 6719cff2af
38 changed files with 469 additions and 170 deletions

View File

@ -30,9 +30,9 @@ public class CmpImmWithRm8Tests
// Check the first operand (CL)
var clOperand = instructions[0].StructuredOperands[0];
Assert.IsType<RegisterOperand>(clOperand);
var registerOperand = (RegisterOperand)clOperand;
Assert.Equal(RegisterIndex.C, registerOperand.Register);
Assert.IsType<Register8Operand>(clOperand);
var registerOperand = (Register8Operand)clOperand;
Assert.Equal(RegisterIndex8.CL, registerOperand.Register);
Assert.Equal(8, registerOperand.Size); // Validate that it's an 8-bit register (CL)
// Check the second operand (immediate value)

View File

@ -32,10 +32,9 @@ public class CmpInstructionSequenceTests
// Check the first operand (memory operand)
var memoryOperand = instruction.StructuredOperands[0];
Assert.IsType<DisplacementMemoryOperand>(memoryOperand);
var memory = (DisplacementMemoryOperand)memoryOperand;
Assert.Equal(RegisterIndex.Bp, memory.BaseRegister); // Base register is EBP
Assert.Equal(0, memory.Displacement); // Displacement is 0
Assert.IsType<BaseRegisterMemoryOperand>(memoryOperand);
var memory = (BaseRegisterMemoryOperand)memoryOperand;
Assert.Equal(RegisterIndex.Bp, memory.BaseRegister); // Base register is ECX
Assert.Equal(8, memory.Size); // Memory size is 8 bits (BYTE)
// Check the second operand (immediate value)
@ -72,10 +71,9 @@ public class CmpInstructionSequenceTests
// Check the first operand (memory operand)
var memoryOperand = cmpInstruction.StructuredOperands[0];
Assert.IsType<DisplacementMemoryOperand>(memoryOperand);
var memory = (DisplacementMemoryOperand)memoryOperand;
Assert.Equal(RegisterIndex.Bp, memory.BaseRegister); // Base register is EBP
Assert.Equal(0, memory.Displacement); // Displacement is 0
Assert.IsType<BaseRegisterMemoryOperand>(memoryOperand);
var memory = (BaseRegisterMemoryOperand)memoryOperand;
Assert.Equal(RegisterIndex.Bp, memory.BaseRegister); // Base register is ECX
Assert.Equal(8, memory.Size); // Memory size is 8 bits (BYTE)
// Check the second operand (immediate value)
@ -108,7 +106,6 @@ public class CmpInstructionSequenceTests
public void CmpJgeSequence_DecodesCorrectly()
{
// Arrange
// This is the sequence from address 0x00001C46
// CMP BYTE PTR [EBP], 0x03 (80 7D 00 03)
// JGE +5 (7D 05)
// ADD EBP, 0x18 (83 C5 18)
@ -135,10 +132,9 @@ public class CmpInstructionSequenceTests
// Check the first operand (memory operand)
var memoryOperand = cmpInstruction.StructuredOperands[0];
Assert.IsType<DisplacementMemoryOperand>(memoryOperand);
var memory = (DisplacementMemoryOperand)memoryOperand;
Assert.Equal(RegisterIndex.Bp, memory.BaseRegister); // Base register is EBP
Assert.Equal(0, memory.Displacement); // Displacement is 0
Assert.IsType<BaseRegisterMemoryOperand>(memoryOperand);
var memory = (BaseRegisterMemoryOperand)memoryOperand;
Assert.Equal(RegisterIndex.Bp, memory.BaseRegister); // Base register is ECX
Assert.Equal(8, memory.Size); // Memory size is 8 bits (BYTE)
// Check the second operand (immediate value)

View File

@ -34,9 +34,9 @@ public class Group1InstructionTests
// Check the first operand (AL)
var alOperand = instruction.StructuredOperands[0];
Assert.IsType<RegisterOperand>(alOperand);
var registerOperand = (RegisterOperand)alOperand;
Assert.Equal(RegisterIndex.A, registerOperand.Register);
Assert.IsType<Register8Operand>(alOperand);
var registerOperand = (Register8Operand)alOperand;
Assert.Equal(RegisterIndex8.AL, registerOperand.Register);
Assert.Equal(8, registerOperand.Size); // Validate that it's an 8-bit register (AL)
// Check the second operand (immediate value)
@ -110,9 +110,9 @@ public class Group1InstructionTests
// Check the first operand (BL)
var blOperand = instruction.StructuredOperands[0];
Assert.IsType<RegisterOperand>(blOperand);
var registerOperand = (RegisterOperand)blOperand;
Assert.Equal(RegisterIndex.B, registerOperand.Register);
Assert.IsType<Register8Operand>(blOperand);
var registerOperand = (Register8Operand)blOperand;
Assert.Equal(RegisterIndex8.BL, registerOperand.Register);
Assert.Equal(8, registerOperand.Size); // Validate that it's an 8-bit register (BL)
// Check the second operand (immediate value)

View File

@ -31,9 +31,9 @@ public class InstructionDecoderTests
// Check the first operand (AH)
var ahOperand = instruction.StructuredOperands[0];
Assert.IsType<RegisterOperand>(ahOperand);
var ahRegisterOperand = (RegisterOperand)ahOperand;
Assert.Equal(RegisterIndex.A, ahRegisterOperand.Register);
Assert.IsType<Register8Operand>(ahOperand);
var ahRegisterOperand = (Register8Operand)ahOperand;
Assert.Equal(RegisterIndex8.AH, ahRegisterOperand.Register);
Assert.Equal(8, ahRegisterOperand.Size); // Validate that it's an 8-bit register (AH)
// Check the second operand (immediate value)
@ -66,9 +66,9 @@ public class InstructionDecoderTests
// Check the first operand (CL)
var clOperand = instruction.StructuredOperands[0];
Assert.IsType<RegisterOperand>(clOperand);
var clRegisterOperand = (RegisterOperand)clOperand;
Assert.Equal(RegisterIndex.C, clRegisterOperand.Register);
Assert.IsType<Register8Operand>(clOperand);
var clRegisterOperand = (Register8Operand)clOperand;
Assert.Equal(RegisterIndex8.CL, clRegisterOperand.Register);
Assert.Equal(8, clRegisterOperand.Size); // Validate that it's an 8-bit register (CL)
// Check the second operand (AL)
@ -247,9 +247,9 @@ public class InstructionDecoderTests
// Check the first operand (AH)
var ahOperand = instruction1.StructuredOperands[0];
Assert.IsType<RegisterOperand>(ahOperand);
var ahRegisterOperand = (RegisterOperand)ahOperand;
Assert.Equal(RegisterIndex.A, ahRegisterOperand.Register);
Assert.IsType<Register8Operand>(ahOperand);
var ahRegisterOperand = (Register8Operand)ahOperand;
Assert.Equal(RegisterIndex8.AH, ahRegisterOperand.Register);
Assert.Equal(8, ahRegisterOperand.Size); // Validate that it's an 8-bit register (AH)
// Check the second operand (immediate value)

View File

@ -196,10 +196,10 @@ public class InstructionSequenceTests
// Check the first operand (AL)
var alOperand = instructions[5].StructuredOperands[0];
Assert.IsType<RegisterOperand>(alOperand);
registerOperand = (RegisterOperand)alOperand;
Assert.Equal(RegisterIndex.A, registerOperand.Register);
Assert.Equal(8, registerOperand.Size); // Validate that it's an 8-bit register (AL)
Assert.IsType<Register8Operand>(alOperand);
var registerOperand2 = (Register8Operand)alOperand;
Assert.Equal(RegisterIndex8.AL, registerOperand2.Register);
Assert.Equal(8, registerOperand2.Size); // Validate that it's an 8-bit register (AL)
// Check the second operand (memory operand)
memOperand = instructions[5].StructuredOperands[1];

View File

@ -31,9 +31,9 @@ public class MovRm8Imm8Tests
// Check the first operand (AL)
var alOperand = instruction.StructuredOperands[0];
Assert.IsType<RegisterOperand>(alOperand);
var registerOperand = (RegisterOperand)alOperand;
Assert.Equal(RegisterIndex.A, registerOperand.Register);
Assert.IsType<Register8Operand>(alOperand);
var registerOperand = (Register8Operand)alOperand;
Assert.Equal(RegisterIndex8.AL, registerOperand.Register);
Assert.Equal(8, registerOperand.Size); // Validate that it's an 8-bit register (AL)
// Check the second operand (immediate value)

View File

@ -31,9 +31,9 @@ public class OrInstructionTests
// Check the first operand (CL)
var clOperand = instruction.StructuredOperands[0];
Assert.IsType<RegisterOperand>(clOperand);
var registerOperand1 = (RegisterOperand)clOperand;
Assert.Equal(RegisterIndex.C, registerOperand1.Register);
Assert.IsType<Register8Operand>(clOperand);
var registerOperand1 = (Register8Operand)clOperand;
Assert.Equal(RegisterIndex8.CL, registerOperand1.Register);
Assert.Equal(8, registerOperand1.Size); // Validate that it's an 8-bit register (CL)
// Check the second operand (AL)
@ -67,9 +67,9 @@ public class OrInstructionTests
// Check the first operand (AL)
var alOperand = instruction.StructuredOperands[0];
Assert.IsType<RegisterOperand>(alOperand);
var registerOperand = (RegisterOperand)alOperand;
Assert.Equal(RegisterIndex.A, registerOperand.Register);
Assert.IsType<Register8Operand>(alOperand);
var registerOperand = (Register8Operand)alOperand;
Assert.Equal(RegisterIndex8.AL, registerOperand.Register);
Assert.Equal(8, registerOperand.Size); // Validate that it's an 8-bit register (AL)
// Check the second operand (memory operand)

View File

@ -74,9 +74,9 @@ public class OrRm8R8HandlerTests
// Check the first operand (BL)
var blOperand = instruction.StructuredOperands[0];
Assert.IsType<RegisterOperand>(blOperand);
var registerOperand1 = (RegisterOperand)blOperand;
Assert.Equal(RegisterIndex.B, registerOperand1.Register);
Assert.IsType<Register8Operand>(blOperand);
var registerOperand1 = (Register8Operand)blOperand;
Assert.Equal(RegisterIndex8.BL, registerOperand1.Register);
Assert.Equal(8, registerOperand1.Size); // Validate that it's an 8-bit register (BL)
// Check the second operand (CH)

View File

@ -33,9 +33,9 @@ public class SubRm8Imm8Tests
// Check the first operand (BL)
var blOperand = instruction.StructuredOperands[0];
Assert.IsType<RegisterOperand>(blOperand);
var registerOperand = (RegisterOperand)blOperand;
Assert.Equal(RegisterIndex.B, registerOperand.Register);
Assert.IsType<Register8Operand>(blOperand);
var registerOperand = (Register8Operand)blOperand;
Assert.Equal(RegisterIndex8.BL, registerOperand.Register);
Assert.Equal(8, registerOperand.Size); // Validate that it's an 8-bit register (BL)
// Check the second operand (immediate value)

View File

@ -73,9 +73,9 @@ public class TestInstructionHandlerTests
// Check the first operand (CL)
var clOperand = instruction.StructuredOperands[0];
Assert.IsType<RegisterOperand>(clOperand);
var registerOperand1 = (RegisterOperand)clOperand;
Assert.Equal(RegisterIndex.C, registerOperand1.Register);
Assert.IsType<Register8Operand>(clOperand);
var registerOperand1 = (Register8Operand)clOperand;
Assert.Equal(RegisterIndex8.CL, registerOperand1.Register);
Assert.Equal(8, registerOperand1.Size); // Validate that it's an 8-bit register (CL)
// Check the second operand (AL)
@ -188,9 +188,9 @@ public class TestInstructionHandlerTests
// Check the first operand (AH)
var ahOperand = instruction.StructuredOperands[0];
Assert.IsType<RegisterOperand>(ahOperand);
var registerOperand = (RegisterOperand)ahOperand;
Assert.Equal(RegisterIndex.A, registerOperand.Register);
Assert.IsType<Register8Operand>(ahOperand);
var registerOperand = (Register8Operand)ahOperand;
Assert.Equal(RegisterIndex8.AH, registerOperand.Register);
Assert.Equal(8, registerOperand.Size); // Validate that it's an 8-bit register (AH)
// Check the second operand (immediate value)