mirror of
https://github.com/mii443/AzooKeyKanaKanjiConverter.git
synced 2025-08-22 15:05:26 +00:00
Merge pull request #224 from azooKey/refactor/remove_complicated_boundary_checker
refactor: 特定のローマ字かな変換テーブルを前提にした複雑な境界チェックを廃止する
This commit is contained in:
@ -175,6 +175,21 @@ final class DicdataStoreTests: XCTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
/// 入力誤りを確実に修正できてほしい語群
|
||||
func testMustCorrectTypoRoman2Kana() throws {
|
||||
let dicdataStore = DicdataStore(convertRequestOptions: requestOptions())
|
||||
let mustWords = [
|
||||
("tskamatsu", "高松"), // ts -> タ
|
||||
("kitsmura", "北村"), // ts -> タ
|
||||
]
|
||||
for (key, word) in mustWords {
|
||||
var c = ComposingText()
|
||||
c.insertAtCursorPosition(key, inputStyle: .roman2kana)
|
||||
let result = dicdataStore.lookupDicdata(composingText: c, inputRange: (0, c.input.endIndex - 1 ..< c.input.endIndex), needTypoCorrection: true)
|
||||
XCTAssertEqual(result.first(where: {$0.data.word == word})?.data.word, word)
|
||||
}
|
||||
}
|
||||
|
||||
func testLookupDicdata() throws {
|
||||
let dicdataStore = DicdataStore(convertRequestOptions: requestOptions())
|
||||
do {
|
||||
@ -209,6 +224,12 @@ final class DicdataStoreTests: XCTestCase {
|
||||
var c = ComposingText()
|
||||
sequentialInput(&c, sequence: "tukatt", inputStyle: .roman2kana)
|
||||
let result = dicdataStore.lookupDicdata(composingText: c, inputRange: (0, 4..<6))
|
||||
XCTAssertFalse(result.contains(where: {$0.data.word == "使っ"}))
|
||||
}
|
||||
do {
|
||||
var c = ComposingText()
|
||||
sequentialInput(&c, sequence: "tukatt", inputStyle: .roman2kana)
|
||||
let result = dicdataStore.lookupDicdata(composingText: c, surfaceRange: (0, nil))
|
||||
XCTAssertTrue(result.contains(where: {$0.data.word == "使っ"}))
|
||||
}
|
||||
}
|
||||
@ -288,9 +309,14 @@ final class DicdataStoreTests: XCTestCase {
|
||||
do {
|
||||
var c = ComposingText()
|
||||
sequentialInput(&c, sequence: "tesutowaーdo", inputStyle: .roman2kana)
|
||||
let result = dicdataStore.lookupDicdata(composingText: c, inputRange: (0, c.input.endIndex - 1 ..< c.input.endIndex), needTypoCorrection: false)
|
||||
let result = dicdataStore.lookupDicdata(
|
||||
composingText: c,
|
||||
inputRange: (0, c.input.endIndex - 1 ..< c.input.endIndex),
|
||||
surfaceRange: (0, c.convertTarget.count - 1 ..< c.convertTarget.count),
|
||||
needTypoCorrection: false
|
||||
)
|
||||
XCTAssertTrue(result.contains(where: {$0.data.word == "テストワード"}))
|
||||
XCTAssertEqual(result.first(where: {$0.data.word == "テストワード"})?.range, .input(from: 0, to: 11))
|
||||
XCTAssertEqual(result.first(where: {$0.data.word == "テストワード"})?.range, .surface(from: 0, to: 6))
|
||||
}
|
||||
|
||||
// 動的ユーザ辞書の単語が通常の辞書よりも優先されることのテスト
|
||||
|
Reference in New Issue
Block a user