示例工程 29-testing-swift-testing

29-testing-swift-testing/Sources/Ch29Demo/App.swift

swift · 0.9 KB

import Ch29Kit
 
@main
struct Ch29Demo {
    static func main() {
        print("[29.1] 0 点 = \(Greeting.text(for: "Ada", hour: 0))")
        print("[29.1] 9 点 = \(Greeting.text(for: "Ada", hour: 9))")
        print("[29.1] 14 点 = \(Greeting.text(for: "Ada", hour: 14))")
        print("[29.1] 21 点 = \(Greeting.text(for: "Ada", hour: 21))")
 
        print("[29.2] 固定时钟 = \(Scheduler.greeting(name: "Ada", time: FixedTime(hour: 9)))")
        print(
            "[29.3] 解析 = \(Parsing.positive("42").map(String.init) ?? "nil")/\(Parsing.positive("-1").map(String.init) ?? "nil")"
        )
 
        let report = Report.render([
            Item(name: "bob", score: 80),
            Item(name: "ada", score: 95),
            Item(name: "cy", score: 88),
        ])
        print("[29.4] 快照:")
        print(report)
 
        print("[29.5] MemoryLayout<FixedTime> = \(MemoryLayout<FixedTime>.size) 字节")
    }
}