Files
kangkang/康康Tests/MedicationReminderParsingTests.swift
link2026 9d856fcfc4 ```
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,使用信号量闸门控制显存占用
- 更新文档中的技术栈说明、模块边界和周次交付计划
```
2026-06-15 09:24:59 +08:00

46 lines
1.9 KiB
Swift

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 == "餐后 · 一日两次")
}
}