测试函数需要* os.File作为参数

时间:2015-12-22 22:51:13

标签: go

我想为bellow函数编写测试,但我无法理解我可以作为let notification = UILocalNotification() notification.fireDate = NSDate(timeIntervalSinceNow: 5) notification.alertBody = "Hey you!" notification.alertAction = "be awesome!" notification.soundName = UILocalNotificationDefaultSoundName notification.userInfo = ["key": "value"] UIApplication.sharedApplication().scheduleLocalNotification(notification) 的参数发送什么,因为我不想打开/创建文件,我知道os.Stdin会起作用,但我认为你不能写入它。

toCount

1 个答案:

答案 0 :(得分:2)

您的toCount功能只需要io.Reader。如果您将签名更改为

func toCount(f io.Reader) int

它可以接受*os.File以及您要用来测试的任何其他类型的阅读器。