mirror of
https://github.com/anomalyco/hex.git
synced 2026-11-28 13:02:21 +01:00
TypingDecoderModel keeps its file's URL and opens the core's model on it on first use, from any thread. Nothing calls it yet: the keyboard behaves as before. KeyboardCoreLinkTests checks the core links and reads the bundled English model.
24 lines
910 B
Swift
24 lines
910 B
Swift
import HexKeyboardCore
|
|
import XCTest
|
|
@testable import HEX
|
|
|
|
/// The keyboard's Rust core (`crates/keyboard`) links into the app and opens the model the
|
|
/// keyboard ships.
|
|
@MainActor
|
|
final class KeyboardCoreLinkTests: XCTestCase {
|
|
func testTheCoreIsTheHeadersVersion() {
|
|
XCTAssertEqual(hk_abi_version(), UInt32(HK_ABI_VERSION))
|
|
}
|
|
|
|
func testTheCoreOpensTheBundledEnglishModel() throws {
|
|
let model = try XCTUnwrap(TypingDecoderModel.bundled("en"), "the English model is bundled")
|
|
let core = try XCTUnwrap(KeyboardCoreModel(url: model.url))
|
|
XCTAssertEqual(core.wordCount, 86_133)
|
|
XCTAssertEqual(model.core?.wordCount, model.wordCount)
|
|
XCTAssertTrue(model.core === model.core, "opened once")
|
|
}
|
|
|
|
func testTheCoreOpensNothingWhereThereIsNoModel() {
|
|
XCTAssertNil(KeyboardCoreModel(url: URL(fileURLWithPath: "/nonexistent/en.hextm")))
|
|
}
|
|
}
|