f0240c3088
- Accumulate utterance PCM in FlowContinuousCapture for batch retry - Run full-utterance transcribeChunk when stitched final lags partial - Refactor Mac MLX tail drain to shared FlowUtteranceEndCoordinator - Add FlowUtterancePCMStore, UtteranceBatchFallbackPolicy, and tests Co-authored-by: Rocky <hkgood@users.noreply.github.com>
46 lines
1.4 KiB
Swift
46 lines
1.4 KiB
Swift
// UtteranceBatchFallbackPolicyTests.swift
|
|
// OSGKeyboardTests
|
|
|
|
import XCTest
|
|
@testable import OSGKeyboardShared
|
|
|
|
final class UtteranceBatchFallbackPolicyTests: XCTestCase {
|
|
|
|
func testShouldRunWhenPartialClearlyLonger() {
|
|
XCTAssertTrue(
|
|
UtteranceBatchFallbackPolicy.shouldRunBatchFallback(
|
|
stitchedFinal: "今天很好",
|
|
partialSnapshot: "今天很好,我们一起去公园吧"
|
|
)
|
|
)
|
|
}
|
|
|
|
func testShouldRunWhenFinalEmptyButPartialPresent() {
|
|
XCTAssertTrue(
|
|
UtteranceBatchFallbackPolicy.shouldRunBatchFallback(
|
|
stitchedFinal: "",
|
|
partialSnapshot: "最后一段"
|
|
)
|
|
)
|
|
}
|
|
|
|
func testShouldNotRunWhenPartialNotLonger() {
|
|
XCTAssertFalse(
|
|
UtteranceBatchFallbackPolicy.shouldRunBatchFallback(
|
|
stitchedFinal: "今天很好,我们一起去公园吧",
|
|
partialSnapshot: "今天很好"
|
|
)
|
|
)
|
|
}
|
|
|
|
func testPreferredTranscriptPicksLongestCandidate() {
|
|
let resolved = UtteranceBatchFallbackPolicy.preferredTranscript(
|
|
batch: "今天很好,我们一起去公园吧",
|
|
stitchedFinal: "今天很好",
|
|
partialSnapshot: "今天很好,我们",
|
|
current: "今天很好,我们"
|
|
)
|
|
XCTAssertEqual(resolved, "今天很好,我们一起去公园吧")
|
|
}
|
|
}
|