From
http://golang.org/pkg/testing/, it says
The (testing) package also runs and verifies example code. ... line comment that begins with "Output:" and is compared with the standard output of the function when the tests are run. (The comparison ignores leading and trailing space.)
Does the space here include tabs?
This is my Example actual output:
flags.Bool("debug", false, "Turn on debugging.")
viper.BindPFlag("debug", flags.Lookup("debug"))
I.e., it has a leading tab in each line.
This is my Example output comment section:
// Output:
// flags.Bool("debug", false, "Turn on debugging.")
// viper.BindPFlag("debug", flags.Lookup("debug"))
They are exactly from the actual output, character by character. The only differences are the leading and trailing spaces. But this is my test result:
=== RUN: ExampleCommandLineCobraViper
--- FAIL: ExampleCommandLineCobraViper (0.00s)
got:
flags.Bool("debug", false, "Turn on debugging.")
viper.BindPFlag("debug", flags.Lookup("debug"))
want:
flags.Bool("debug", false, "Turn on debugging.")
viper.BindPFlag("debug", flags.Lookup("debug"))
FAIL
exit status 1
- How to make it working?
- If my actual output contains more lines, but have blank lines in between them, should I include the blank lines in the output comment or not?
flags.Bool("debug", false, "Turn on debugging.")
viper.BindPFlag("debug", flags.Lookup("debug"))
flags.String("addr", "localhost:5002", "Address of the service.")
viper.BindPFlag("addr", flags.Lookup("addr"))
Thanks