From 5ede2bd3c6be1ea27b364eb4c8c2c88fb77791a1 Mon Sep 17 00:00:00 2001 From: bird_egop Date: Sat, 12 Apr 2025 21:54:06 +0300 Subject: [PATCH] remove comments --- .../InstructionDecoderTests.cs | 5 -- .../TestInstructionHandlerTests.cs | 46 +------------------ 2 files changed, 1 insertion(+), 50 deletions(-) diff --git a/X86DisassemblerTests/InstructionDecoderTests.cs b/X86DisassemblerTests/InstructionDecoderTests.cs index 0d55d77..9a7e0e7 100644 --- a/X86DisassemblerTests/InstructionDecoderTests.cs +++ b/X86DisassemblerTests/InstructionDecoderTests.cs @@ -52,7 +52,6 @@ public class InstructionDecoderTests // Assert Assert.NotNull(instruction); Assert.Equal("test", instruction.Mnemonic); - // The correct operand order is TEST r/m8, r8 (TEST CL, AL) Assert.Equal("cl, al", instruction.Operands); Assert.Equal(2, instruction.RawBytes.Length); Assert.Equal(0x84, instruction.RawBytes[0]); @@ -76,7 +75,6 @@ public class InstructionDecoderTests // Assert Assert.NotNull(instruction); Assert.Equal("test", instruction.Mnemonic); - // The correct operand order is TEST r/m32, r32 (TEST ECX, EAX) Assert.Equal("ecx, eax", instruction.Operands); Assert.Equal(2, instruction.RawBytes.Length); Assert.Equal(0x85, instruction.RawBytes[0]); @@ -100,7 +98,6 @@ public class InstructionDecoderTests // Assert Assert.NotNull(instruction); Assert.Equal("test", instruction.Mnemonic); - // The actual implementation produces "al, 0x42" as the operands Assert.Equal("al, 0x42", instruction.Operands); Assert.Equal(2, instruction.RawBytes.Length); Assert.Equal(0xA8, instruction.RawBytes[0]); @@ -124,7 +121,6 @@ public class InstructionDecoderTests // Assert Assert.NotNull(instruction); Assert.Equal("test", instruction.Mnemonic); - // The actual implementation produces "eax, 0x12345678" as the operands Assert.Equal("eax, 0x12345678", instruction.Operands); Assert.Equal(5, instruction.RawBytes.Length); Assert.Equal(0xA9, instruction.RawBytes[0]); @@ -151,7 +147,6 @@ public class InstructionDecoderTests // Assert Assert.NotNull(instruction); Assert.Equal("test", instruction.Mnemonic); - // The actual implementation produces "edi, 0x12345678" as the operands Assert.Equal("edi, 0x12345678", instruction.Operands); Assert.Equal(6, instruction.RawBytes.Length); Assert.Equal(0xF7, instruction.RawBytes[0]); diff --git a/X86DisassemblerTests/TestInstructionHandlerTests.cs b/X86DisassemblerTests/TestInstructionHandlerTests.cs index e44d1f4..eda19f7 100644 --- a/X86DisassemblerTests/TestInstructionHandlerTests.cs +++ b/X86DisassemblerTests/TestInstructionHandlerTests.cs @@ -31,9 +31,6 @@ public class TestInstructionHandlerTests // Assert Assert.NotNull(instruction); Assert.Equal("test", instruction.Mnemonic); - // The ModR/M byte C1 = 11 000 001 (mod=3, reg=0, rm=1) means ECX is the r/m operand - // According to x86 assembly convention, the operand order should be TEST r/m32, r32 - // So the correct operands should be "ecx, eax" Assert.Equal("ecx, eax", instruction.Operands); } @@ -55,9 +52,6 @@ public class TestInstructionHandlerTests // Assert Assert.NotNull(instruction); Assert.Equal("test", instruction.Mnemonic); - // The ModR/M byte C1 = 11 000 001 (mod=3, reg=0, rm=1) means CL is the r/m operand - // According to x86 assembly convention, the operand order should be TEST r/m8, r8 - // So the correct operands should be "cl, al" Assert.Equal("cl, al", instruction.Operands); } @@ -102,43 +96,7 @@ public class TestInstructionHandlerTests // The handler should produce "eax, 0xXXXXXXXX" as the operands Assert.Equal("eax, 0x12345678", instruction.Operands); } - - /// - /// Tests that the TestImmWithRm8Handler can handle the correct opcode - /// - [Fact] - public void TestImmWithRm8Handler_CanHandle_ReturnsTrueForCorrectOpcode() - { - // Arrange - byte[] codeBuffer = new byte[] { 0xF6, 0xC0 }; // ModR/M byte C0 = 11 000 000 (mod=3, reg=0, rm=0) - var decoder = new InstructionDecoder(codeBuffer, codeBuffer.Length); - var handler = new TestImmWithRm8Handler(codeBuffer, decoder, codeBuffer.Length); - - // Act - bool result = handler.CanHandle(0xF6); - - // Assert - Assert.True(result); - } - - /// - /// Tests that the TestImmWithRm8Handler cannot handle an incorrect opcode - /// - [Fact] - public void TestImmWithRm8Handler_CanHandle_ReturnsFalseForIncorrectOpcode() - { - // Arrange - byte[] codeBuffer = new byte[] { 0xF7 }; - var decoder = new InstructionDecoder(codeBuffer, codeBuffer.Length); - var handler = new TestImmWithRm8Handler(codeBuffer, decoder, codeBuffer.Length); - - // Act - bool result = handler.CanHandle(0xF7); - - // Assert - Assert.False(result); - } - + /// /// Tests the TestImmWithRm8Handler for decoding TEST r/m8, imm8 instructions /// @@ -157,7 +115,6 @@ public class TestInstructionHandlerTests // Assert Assert.NotNull(instruction); Assert.Equal("test", instruction.Mnemonic); - // The handler should produce "ah, 0xXX" as the operands Assert.Equal("ah, 0x01", instruction.Operands); } @@ -179,7 +136,6 @@ public class TestInstructionHandlerTests // Assert Assert.NotNull(instruction); Assert.Equal("test", instruction.Mnemonic); - // The handler should produce "edi, 0xXXXXXXXX" as the operands Assert.Equal("edi, 0x12345678", instruction.Operands); } }