Files
AzooKeyKanaKanjiConverter/Tests/KanaKanjiConverterModuleTests/InputStyleManagerTests.swift
Miwa d8b06e9367 Merge pull request #227 from azooKey/feat/mapped_input_style
feat: `.mapped(id)`を新たな入力スタイルとして導入し、カスタムローマ字かな変換テーブルに対応
2025-07-23 23:35:36 +09:00

29 lines
1.5 KiB
Swift

@testable import KanaKanjiConverterModule
import XCTest
final class InputStyleManagerTests: XCTestCase {
func testCustomTableLoading() throws {
let url = FileManager.default.temporaryDirectory.appendingPathComponent("custom.tsv")
try "a\t\nka\t\n".write(to: url, atomically: true, encoding: .utf8)
let table = InputStyleManager.shared.table(for: .custom(url))
XCTAssertEqual(table.toHiragana(currentText: [], added: "a"), Array(""))
XCTAssertEqual(table.toHiragana(currentText: ["k"], added: "a"), Array(""))
}
func testCustomTableLoadingWithBlankLines() throws {
let url = FileManager.default.temporaryDirectory.appendingPathComponent("custom.tsv")
try "a\t\n\n\nka\t\n".write(to: url, atomically: true, encoding: .utf8)
let table = InputStyleManager.shared.table(for: .custom(url))
XCTAssertEqual(table.toHiragana(currentText: [], added: "a"), Array(""))
XCTAssertEqual(table.toHiragana(currentText: ["k"], added: "a"), Array(""))
}
func testCustomTableLoadingWithCommentLines() throws {
let url = FileManager.default.temporaryDirectory.appendingPathComponent("custom.tsv")
try "a\t\n# here is comment\nka\t\n".write(to: url, atomically: true, encoding: .utf8)
let table = InputStyleManager.shared.table(for: .custom(url))
XCTAssertEqual(table.toHiragana(currentText: [], added: "a"), Array(""))
XCTAssertEqual(table.toHiragana(currentText: ["k"], added: "a"), Array(""))
}
}