Skip to content

Commit

Permalink
add failing case
Browse files Browse the repository at this point in the history
  • Loading branch information
ensan-hcl committed Feb 27, 2024
1 parent cda10cc commit ea0219e
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit ea0219e

Please sign in to comment.