From 8638f8a9aadf7149f17872cc45dd6afb6725f332 Mon Sep 17 00:00:00 2001 From: tfarcraw <123211521@163.com> Date: Thu, 19 Nov 2026 02:16:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=A1=E8=AE=A1=E6=B8=85=E5=8D=95=E6=97=A0?= =?UTF-8?q?=E6=95=88=E6=88=96=E6=AD=A3=E5=8F=8D=E5=AF=B9=E7=85=A7=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E6=97=B6=E8=BF=94=E5=9B=9E=E5=A4=B1=E8=B4=A5=E7=8A=B6?= =?UTF-8?q?=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/VideoFlowTest.Smoke/EvidenceAuditChecks.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/VideoFlowTest.Smoke/EvidenceAuditChecks.cs b/tests/VideoFlowTest.Smoke/EvidenceAuditChecks.cs index c9c1f5e..b6ec4ad 100644 --- a/tests/VideoFlowTest.Smoke/EvidenceAuditChecks.cs +++ b/tests/VideoFlowTest.Smoke/EvidenceAuditChecks.cs @@ -14,6 +14,7 @@ internal static class EvidenceAuditChecks var original = File.ReadAllBytes(configPath); var config = SopConfigLoader.Load(configPath); var cases = JsonSerializer.Deserialize(File.ReadAllText(manifestPath), new JsonSerializerOptions { PropertyNameCaseInsensitive = true })!; + if (cases is null || cases.Length == 0) throw new ArgumentException("审计清单不能为空"); using var settings = JsonDocument.Parse(File.ReadAllText(settingsPath)); var root = settings.RootElement; string Text(string key) => root.TryGetProperty(key, out var value) ? value.GetString() ?? "" : ""; @@ -30,8 +31,10 @@ internal static class EvidenceAuditChecks var frames = new List(); foreach (var seconds in sample.Times) { + if (!double.IsFinite(seconds) || seconds < 0 || seconds >= capture.FrameCount / capture.Fps) + throw new ArgumentException("审计证据时间超出视频范围"); var id = (long)Math.Round(seconds * capture.Fps); - capture.Set(VideoCaptureProperties.PosFrames, id); + if (!capture.Set(VideoCaptureProperties.PosFrames, id)) throw new IOException("无法定位审计原始帧"); using var image = new Mat(); if (!capture.Read(image) || image.Empty()) throw new IOException("无法读取审计证据"); var mode = VisionImageMode.Resolve(options); @@ -68,5 +71,6 @@ internal static class EvidenceAuditChecks new JsonSerializerOptions { WriteIndented = true })); Console.WriteLine($"审计步骤 {sample.StepId} {sample.Kind}: 正确={correct}, 放行={accepted}, 期望={sample.ExpectedCompleted}, {decision?.Reason ?? error}"); } + if (!allCorrect) throw new InvalidOperationException("正例或边界反例未通过,详见报告:" + reportPath); } }