Skip to content

Commit

Permalink
Merge pull request #238 from mtgto/empty-candidate2
Browse files Browse the repository at this point in the history
送り仮名ブロックを含む複数の変換候補をもつ場合にパースできないバグを修正
  • Loading branch information
mtgto authored Oct 27, 2024
2 parents a0a183a + a93187d commit f5504bc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions macSKK/Entry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ struct Entry: Sendable {
result.append(parseWord(wordsText.dropLast(), dictId: dictId))
wordsText = array[1].dropFirst()
}
continue
}
}
let array = wordsText.split(separator: "/", maxSplits: 1)
Expand Down
17 changes: 11 additions & 6 deletions macSKKTests/EntryTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ final class EntryTests: XCTestCase {
entry = Entry(line: "かっこ /[/", dictId: "")
XCTAssertEqual(entry?.yomi, "かっこ")
XCTAssertEqual(entry?.candidates, [Word("[")])
// 空の変換候補だけスキップ
entry = Entry(line: "い /胃//意/", dictId: "")
XCTAssertEqual(entry?.candidates, [Word(""), Word("")])
entry = Entry(line: "い /胃/意//", dictId: "")
XCTAssertEqual(entry?.candidates, [Word(""), Word("")])
// 送り仮名ブロックの変換候補が空
entry = Entry(line: "いt /[った//]/", dictId: "")
XCTAssertEqual(entry?.candidates, [])
// 送り仮名ブロックが閉じていない
entry = Entry(line: "いt /[った/行/", dictId: "")
XCTAssertEqual(entry?.candidates, [Word("[った"), Word("")])
}

func testInvalidLine() {
Expand All @@ -56,13 +67,7 @@ final class EntryTests: XCTestCase {
XCTAssertNil(Entry(line: "い/胃/", dictId: ""), "読みと変換候補の間にスペースがない")
XCTAssertNil(Entry(line: "い /胃/", dictId: ""), "読みと変換候補の間にスペースが2つある")
XCTAssertNil(Entry(line: "い /胃/意", dictId: ""), "末尾がスラッシュで終わらない")
// FIXME: 空文字列への変換候補をもつ行はエラーではない
//XCTAssertNil(Entry(line: "い //", dictId: ""), "変換候補が空")
//XCTAssertNil(Entry(line: "い /胃//意/", dictId: ""), "変換候補が空")
//XCTAssertNil(Entry(line: "い /胃/意//", dictId: ""), "変換候補が空")
//XCTAssertNil(Entry(line: "いt /[った//]/", dictId: ""), "送り仮名ブロックの変換候補が空")
XCTAssertNil(Entry(line: "いt /[った/行]/", dictId: ""), "送り仮名ブロックの変換候補の末尾にスラッシュがない")
XCTAssertNil(Entry(line: "いt /[った/行/", dictId: ""), "送り仮名ブロックが閉じていない")
}

func testSerialize() {
Expand Down

0 comments on commit f5504bc

Please sign in to comment.