I have a function in GO that takes input from stdio and writes to stdio. Is there a way to write unit tests for the function?
An example function is:
func double() {
var in int
_, err = fmt.Scanf("%d", &in)
if err==nil{
fmt.Scanf(2*in)
}
else{
log.Fatal("Error Scanning input")
}
}
Note that in the real function I want to test, the I/O spans several lines so its not just as simple as making the result as an integer and return it. I am just giving the example here for reference.