Files
kangkang/康康Tests/RetrievalSummaryTests.swift

23 lines
728 B
Swift
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import Testing
@testable import
struct RetrievalSummaryTests {
@Test func groupsAndCountsPreservingOrder() {
let chips = HealthExportService.RetrievalSummary.groupedChips(
["血压", "血糖", "血压", "血压", "体重"], cap: 8)
#expect(chips == ["血压 ×3", "血糖", "体重"])
}
@Test func capsAndAppendsOverflow() {
let names = (1...12).map { "指标\($0)" }
let chips = HealthExportService.RetrievalSummary.groupedChips(names, cap: 8)
#expect(chips.count == 9)
#expect(chips.last == "+4")
}
@Test func emptyInputGivesEmptyChips() {
#expect(HealthExportService.RetrievalSummary.groupedChips([], cap: 8).isEmpty)
}
}