Files
OSGKeyboard/OSGKeyboardTests/TranscriptLanguageDetectorTests.swift
T
Rocky 498f407585 feat(account): add managed credits and cloud gateway
Introduce optional Apple account-backed credits with scoped gateway access while preserving local and BYOK paths. Refresh assistant behavior, tests, privacy disclosures, docs, and the website for the 2.0 experience.
2026-08-20 11:43:21 +08:00

42 lines
1.8 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
@testable import OSGKeyboardShared
import XCTest
final class TranscriptLanguageDetectorTests: XCTestCase {
func testChineseAndMixedInputPreferChineseGuidance() {
XCTAssertTrue(TranscriptLanguageDetector.prefersChineseGuidance("今天开会讨论 roadmap"))
XCTAssertTrue(TranscriptLanguageDetector.prefersChineseGuidance("把 PRD 发给 Ali review"))
}
func testEnglishJapaneseAndKoreanDoNotPreferChineseGuidance() {
XCTAssertFalse(TranscriptLanguageDetector.prefersChineseGuidance("ship it tomorrow"))
XCTAssertFalse(TranscriptLanguageDetector.prefersChineseGuidance("こんにちは"))
XCTAssertFalse(TranscriptLanguageDetector.prefersChineseGuidance("안녕하세요"))
}
func testNumbersHaveNoScriptSignal() {
XCTAssertEqual(TranscriptLanguageDetector.cjkRatio("12345"), 0)
XCTAssertEqual(TranscriptLanguageDetector.cjkRatio(""), 0)
}
func testHanRangeBoundariesRemainStable() {
let hanScalars = [0x3400, 0x4DBF, 0x4E00, 0x9FFF, 0xF900, 0xFAFF]
.compactMap(UnicodeScalar.init)
.map(String.init)
.joined()
XCTAssertEqual(TranscriptLanguageDetector.cjkRatio(hanScalars), 1)
XCTAssertTrue(RimePinyinAnnotator.containsCJK(hanScalars))
XCTAssertFalse(PersonalDictionary.isEnglishTypingHotword("产品GPT"))
}
func testKanaHangulAndFullwidthLatinAreNotHanIdeographs() {
let nonHan = "こんにちは안녕하세요A"
XCTAssertEqual(TranscriptLanguageDetector.cjkRatio(nonHan), 0)
XCTAssertFalse(RimePinyinAnnotator.containsCJK(nonHan))
XCTAssertTrue(PersonalDictionary.isEnglishTypingHotword("PT"))
}
func testJapaneseTextContainingHanKeepsCurrentHanSignal() {
XCTAssertTrue(TranscriptLanguageDetector.prefersChineseGuidance("日本語"))
}
}