mirror of
https://github.com/mii443/AzooKeyKanaKanjiConverter.git
synced 2025-08-22 15:05:26 +00:00
add failing case
This commit is contained in:
@ -188,6 +188,41 @@ final class InputGraphTests: XCTestCase {
|
||||
XCTAssertNil(inputGraph.nodes.first(where: {$0.character == "さ"}))
|
||||
}
|
||||
|
||||
func testBuildSimpleRoman2KanaInput_7文字_youshou() throws {
|
||||
let correctGraph = CorrectGraph.build(input: [
|
||||
.init(character: "y", inputStyle: .roman2kana),
|
||||
.init(character: "o", inputStyle: .roman2kana),
|
||||
.init(character: "u", inputStyle: .roman2kana),
|
||||
.init(character: "s", inputStyle: .roman2kana),
|
||||
.init(character: "h", inputStyle: .roman2kana),
|
||||
.init(character: "o", inputStyle: .roman2kana),
|
||||
.init(character: "u", inputStyle: .roman2kana),
|
||||
])
|
||||
let inputGraph = InputGraph.build(input: correctGraph)
|
||||
XCTAssertEqual(
|
||||
inputGraph.nodes.first(where: {$0.character == "よ"}),
|
||||
.init(character: "よ", displayedTextRange: .range(0, 1), inputElementsRange: .range(0, 2), correction: .none)
|
||||
)
|
||||
XCTAssertEqual(
|
||||
inputGraph.nodes.first(where: {$0.character == "う" && $0.displayedTextRange.startIndex == 1}),
|
||||
.init(character: "う", displayedTextRange: .range(1, 2), inputElementsRange: .range(2, 3), correction: .none)
|
||||
)
|
||||
XCTAssertEqual(
|
||||
inputGraph.nodes.first(where: {$0.character == "し"}),
|
||||
.init(character: "し", displayedTextRange: .range(2, 3), inputElementsRange: .startIndex(3), groupId: 0, correction: .none)
|
||||
)
|
||||
XCTAssertEqual(
|
||||
inputGraph.nodes.first(where: {$0.character == "ょ"}),
|
||||
.init(character: "ょ", displayedTextRange: .range(3, 4), inputElementsRange: .endIndex(6), groupId: 0,
|
||||
correction: .none)
|
||||
)
|
||||
XCTAssertEqual(
|
||||
inputGraph.nodes.first(where: {$0.character == "う" && $0.displayedTextRange.startIndex == 4}),
|
||||
.init(character: "う", displayedTextRange: .range(4, 5), inputElementsRange: .range(6, 7), correction: .none)
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
func testBuildMixedInput_2文字_ts() throws {
|
||||
let correctGraph = CorrectGraph.build(input: [
|
||||
.init(character: "t", inputStyle: .roman2kana),
|
||||
|
@ -19,7 +19,7 @@ extension Kana2Kanji {
|
||||
// 辞書ルックアップによりconvertGraphを構築
|
||||
print(#file, "lookup", inputGraph)
|
||||
let convertGraph = self.dicdataStore.buildConvertGraph(inputGraph: consume inputGraph, option: option)
|
||||
print(#file, "convert", convertGraph)
|
||||
print(#file, "convert")
|
||||
let result = convertGraph.convertAll(option: option, dicdataStore: self.dicdataStore)
|
||||
return result
|
||||
}
|
||||
@ -81,6 +81,31 @@ final class ExperimentalConversionTests: XCTestCase {
|
||||
XCTAssertTrue(result.joinedPrevs().contains("紫")) // むらさき
|
||||
}
|
||||
|
||||
func testBuildConvertGraph_youshouki() throws {
|
||||
let dicdataStore = DicdataStore(requestOptions: requestOptions())
|
||||
var c = ComposingText()
|
||||
c.insertAtCursorPosition("youshouki", inputStyle: .roman2kana)
|
||||
let correctGraph = CorrectGraph.build(input: c.input)
|
||||
let inputGraph = InputGraph.build(input: consume correctGraph)
|
||||
let convertGraph = dicdataStore.buildConvertGraph(inputGraph: inputGraph, option: requestOptions())
|
||||
XCTAssertEqual(
|
||||
convertGraph.nodes.first {
|
||||
$0.latticeNodes.contains(where: {$0.data.word == "世"})
|
||||
}?.latticeNodes.mapSet {$0.data.ruby}
|
||||
.symmetricDifference(["ヨ", "ヨウ", "ヨウシ", "ヨウショ", "ヨウショウ", "ヨウショウキ"]),
|
||||
[]
|
||||
)
|
||||
}
|
||||
|
||||
func testConversion_youshouki() throws {
|
||||
let dicdataStore = DicdataStore(requestOptions: requestOptions())
|
||||
let kana2kanji = Kana2Kanji(dicdataStore: dicdataStore)
|
||||
var c = ComposingText()
|
||||
c.insertAtCursorPosition("youshouki", inputStyle: .roman2kana)
|
||||
let result = kana2kanji._experimental_all(c, option: requestOptions())
|
||||
XCTAssertTrue(result.joinedPrevs().contains("幼少期")) // ようしょうき
|
||||
}
|
||||
|
||||
func testConversion() throws {
|
||||
let dicdataStore = DicdataStore(requestOptions: requestOptions())
|
||||
let kana2kanji = Kana2Kanji(dicdataStore: dicdataStore)
|
||||
|
Reference in New Issue
Block a user