mirror of
https://github.com/sampletext32/ParkanPlayground.git
synced 2025-06-19 16:08:02 +03:00
add tons of tests
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using CsvHelper.Configuration;
|
||||
using X86Disassembler.X86;
|
||||
using X86Disassembler.X86.Operands;
|
||||
@ -18,60 +19,30 @@ public class TestFromFileEntry
|
||||
RawBytes = rawBytes;
|
||||
Instructions = instructions;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{RawBytes}. {string.Join(";", Instructions)}";
|
||||
}
|
||||
}
|
||||
|
||||
public class TestFromFileInstruction
|
||||
{
|
||||
// Keep the old properties for CSV deserialization
|
||||
public string Mnemonic { get; set; } = string.Empty;
|
||||
public string Operands { get; set; } = string.Empty;
|
||||
|
||||
// Add new properties for comparison with actual Instruction objects
|
||||
public InstructionType Type => ConvertMnemonicToType(Mnemonic);
|
||||
|
||||
public string[] Operands { get; set; } = [];
|
||||
|
||||
// Mnemonic
|
||||
[JsonConverter(typeof(JsonStringEnumConverter<InstructionType>))]
|
||||
public InstructionType Type { get; set; }
|
||||
|
||||
// Parameterless constructor required by CsvHelper
|
||||
public TestFromFileInstruction()
|
||||
{
|
||||
}
|
||||
|
||||
public TestFromFileInstruction(string mnemonic, string operands)
|
||||
public override string ToString()
|
||||
{
|
||||
Mnemonic = mnemonic;
|
||||
Operands = operands;
|
||||
}
|
||||
|
||||
// Helper method to convert mnemonic string to InstructionType
|
||||
private InstructionType ConvertMnemonicToType(string mnemonic)
|
||||
{
|
||||
// Convert mnemonic to InstructionType
|
||||
return mnemonic.ToLowerInvariant() switch
|
||||
{
|
||||
"add" => InstructionType.Add,
|
||||
"adc" => InstructionType.Adc,
|
||||
"and" => InstructionType.And,
|
||||
"call" => InstructionType.Call,
|
||||
"cmp" => InstructionType.Cmp,
|
||||
"dec" => InstructionType.Dec,
|
||||
"inc" => InstructionType.Inc,
|
||||
"int3" => InstructionType.Int,
|
||||
"jmp" => InstructionType.Jmp,
|
||||
"jz" => InstructionType.Jz,
|
||||
"jnz" => InstructionType.Jnz,
|
||||
"jge" => InstructionType.Jge,
|
||||
"lea" => InstructionType.Lea,
|
||||
"mov" => InstructionType.Mov,
|
||||
"nop" => InstructionType.Nop,
|
||||
"or" => InstructionType.Or,
|
||||
"pop" => InstructionType.Pop,
|
||||
"push" => InstructionType.Push,
|
||||
"ret" => InstructionType.Ret,
|
||||
"sbb" => InstructionType.Sbb,
|
||||
"sub" => InstructionType.Sub,
|
||||
"test" => InstructionType.Test,
|
||||
"xchg" => InstructionType.Xchg,
|
||||
"xor" => InstructionType.Xor,
|
||||
_ => InstructionType.Unknown
|
||||
};
|
||||
return $"{Type} {string.Join(",", Operands)}";
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user