import Testing @testable import Ch01Kit @Suite("启动上下文") struct LaunchContextTests { @Test func executableNameDropsDirectoryPrefix() { let context = LaunchContext(arguments: ["/tmp/build/debug/Ch01Demo"]) #expect(context.executableName == "Ch01Demo") #expect(context.mode == .standard) #expect(context.rawArguments.isEmpty) } @Test func verboseFlagSelectsVerboseMode() { let context = LaunchContext(arguments: ["Ch01Demo", "--verbose"]) #expect(context.mode == .verbose) #expect(context.rawArguments == ["--verbose"]) } @Test func argumentsAreSortedForDeterministicOutput() { let context = LaunchContext(arguments: ["Ch01Demo", "--zeta", "--alpha", "--verbose"]) #expect(context.rawArguments == ["--alpha", "--verbose", "--zeta"]) } @Test func emptyArgumentsDoNotCrash() { let context = LaunchContext(arguments: []) #expect(context.executableName.isEmpty) #expect(context.mode == .standard) } }