feat(parser): 支持 Ploss Field1 十六进制解析

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Scottxjw
2026-08-17 10:47:33 +08:00
parent 36c21f03dd
commit 6d56a4a01b
4 changed files with 80 additions and 10 deletions

View File

@@ -87,6 +87,26 @@ public class AnalyzeCommandTests : CommandTestBase
Assert.That(stdout, Does.Contain("Please specify --pure and --foreign for Qfod calibration"));
}
[Test]
public async Task Analyze_Ploss_LegacyFile_HexField1_DecodedCorrectly()
{
var dir = NewDir();
// 旧单行格式 Field1=0C (十六进制) 应被解析为十进制 12
var file = TestFixtures.WriteLegacyPlossLog(
dir,
"singleMold-v1.0-hex2_1-iPhone15-ploss_legacy-20260710-1.log",
new (int, int, int)[] { (500, 3000, 0) },
field1Hex: "0C");
var (code, stdout, _) = await Analyze().RunCaptureAsync("--type", "ploss", "--file", file);
Assert.Multiple(() =>
{
Assert.That(code, Is.EqualTo(0));
Assert.That(stdout, Does.Contain("Total: 1 (TwoLine: 0, Legacy: 1), FOD: 0, Errors: 0"));
});
}
[Test]
public async Task Analyze_Qfod_ValidFiles_ReportsThreshold()
{

View File

@@ -76,6 +76,30 @@ public class ParseCommandTests : CommandTestBase
Assert.That(await Host.LocalDb.PlossRecords.CountAsync(), Is.EqualTo(2));
}
[TestCase("0C", 12)] // 上位 nibble = 0下位 nibble = C
[TestCase("0xFF", 255)] // 标准 0x 前缀
[TestCase("0xff", 255)] // 小写 hex
[TestCase("0A", 10)]
[TestCase("0", 0)] // 纯 0应识别为十进制 0
[TestCase("10", 10)] // 纯十进制:应识别为 10不是 0x10 = 16
public async Task Parse_File_PlossLog_HexField1_DecodedCorrectly(string field1Raw, int expected)
{
var dir = NewDir();
var file = TestFixtures.WritePlossLog(dir, TestFixtures.PlossFileName,
new TestFixtures.PlossTwoLineRow(Field1AsHex: field1Raw));
var (code, stdout, _) = await Parse().RunCaptureAsync("--file", file);
Assert.Multiple(() =>
{
Assert.That(code, Is.EqualTo(0));
Assert.That(stdout, Does.Contain("Ploss: 1"));
});
var record = await Host.LocalDb.PlossRecords.SingleAsync();
Assert.That(record.Field1, Is.EqualTo(expected));
}
[Test]
public async Task Parse_File_WithForceOption_Accepted()
{