```
feat(AI): 集成MNN推理引擎替换MLX作为主AI运行时 - 引入MNN(alibaba) + Arm SME2 + CPU作为主AI运行时,支持A19/iPhone17的 SME2和A17的NEON加速 - 添加MLX Swift作为兜底GPU推理方案,实现双后端切换机制 - 使用单一Qwen3.5-2B多模态模型(1.2GB),替代原有的LLM+VL分离架构 - 实现InferenceEngine.current引擎选择逻辑,真机默认MNN,模拟器回退MLX - 更新AIAgent架构,通过MNNLLMBridge(ObjC++) → MNNBackend进行推理 - 修改队列机制防止并发推理导致OOM,使用信号量闸门控制显存占用 - 更新文档中的技术栈说明、模块边界和周次交付计划 ```
This commit is contained in:
45
康康Tests/MedicationReminderParsingTests.swift
Normal file
45
康康Tests/MedicationReminderParsingTests.swift
Normal file
@@ -0,0 +1,45 @@
|
||||
import Testing
|
||||
import Foundation
|
||||
@testable import 康康
|
||||
|
||||
/// 「用药记录」点药设吃药提醒:行拆分与提醒预填的纯函数测试。
|
||||
/// 入口逻辑见 `TimelineEntryDetailView.medicationBody`。
|
||||
struct MedicationReminderParsingTests {
|
||||
|
||||
// MARK: - 行拆分
|
||||
|
||||
@Test func splitsMultipleLinesAndDropsBlanks() {
|
||||
let content = "缬沙坦胶囊 80mg · 一日一次\n\n二甲双胍 0.5g · 一日三次\n "
|
||||
let lines = TimelineEntryDetailView.medicationLines(content)
|
||||
#expect(lines == ["缬沙坦胶囊 80mg · 一日一次", "二甲双胍 0.5g · 一日三次"])
|
||||
}
|
||||
|
||||
@Test func singleLineNoNewline() {
|
||||
#expect(TimelineEntryDetailView.medicationLines("阿司匹林肠溶片 100mg") == ["阿司匹林肠溶片 100mg"])
|
||||
}
|
||||
|
||||
@Test func emptyContentYieldsNoLines() {
|
||||
#expect(TimelineEntryDetailView.medicationLines("\n \n").isEmpty)
|
||||
}
|
||||
|
||||
// MARK: - 提醒预填
|
||||
|
||||
@Test func splitsNameAndUsageOnMiddot() {
|
||||
let f = TimelineEntryDetailView.medicationReminderFields(forLine: "缬沙坦胶囊 80mg · 一日一次")
|
||||
#expect(f.title.contains("缬沙坦胶囊 80mg")) // 标题带药名+规格(可能含「吃药:」前缀)
|
||||
#expect(!f.title.contains("一日一次")) // 用法不进标题
|
||||
#expect(f.note == "一日一次") // 用法进备注
|
||||
}
|
||||
|
||||
@Test func noUsageGivesEmptyNote() {
|
||||
let f = TimelineEntryDetailView.medicationReminderFields(forLine: "阿司匹林 100mg")
|
||||
#expect(f.title.contains("阿司匹林 100mg"))
|
||||
#expect(f.note.isEmpty)
|
||||
}
|
||||
|
||||
@Test func multipleMiddotsKeepEverythingAfterFirstAsUsage() {
|
||||
let f = TimelineEntryDetailView.medicationReminderFields(forLine: "甲药 · 餐后 · 一日两次")
|
||||
#expect(f.title.contains("甲药"))
|
||||
#expect(f.note == "餐后 · 一日两次")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user