summaryrefslogtreecommitdiffstats
path: root/man/go-testfunc.7
diff options
context:
space:
mode:
Diffstat (limited to 'man/go-testfunc.7')
-rw-r--r--man/go-testfunc.790
1 files changed, 90 insertions, 0 deletions
diff --git a/man/go-testfunc.7 b/man/go-testfunc.7
new file mode 100644
index 0000000..b890934
--- /dev/null
+++ b/man/go-testfunc.7
@@ -0,0 +1,90 @@
+.\" Hey, EMACS: -*- nroff -*-
+.de Vb \" Begin verbatim text
+.ft CW
+.nf
+.ne \\$1
+..
+.de Ve \" End verbatim text
+.ft R
+.fi
+..
+.TH GO-TESTFUNC 7 "2022-03-15"
+.\" Please adjust this date whenever revising the manpage.
+.SH NAME
+go \- tool for managing Go source code
+.SH DESCRIPTION
+The \(oqgo test\(cq command expects to find test, benchmark, and example functions
+in the "*_test.go" files corresponding to the package under test.
+
+A test function is one named TestXxx (where Xxx does not start with a
+lower case letter) and should have the signature,
+
+.Vb 6
+\& func TestXxx(t *testing.T) { ... }
+.Ve
+
+A benchmark function is one named BenchmarkXxx and should have the signature,
+
+.Vb 6
+\& func BenchmarkXxx(b *testing.B) { ... }
+.Ve
+
+A fuzz test is one named FuzzXxx and should have the signature,
+
+.Vb 6
+\& func FuzzXxx(f *testing.F) { ... }
+.Ve
+
+An example function is similar to a test function but, instead of using
+*testing.T to report success or failure, prints output to os.Stdout.
+If the last comment in the function starts with "Output:" then the output
+is compared exactly against the comment (see examples below). If the last
+comment begins with "Unordered output:" then the output is compared to the
+comment, however the order of the lines is ignored. An example with no such
+comment is compiled but not executed. An example with no text after
+"Output:" is compiled, executed, and expected to produce no output.
+
+Godoc displays the body of ExampleXxx to demonstrate the use
+of the function, constant, or variable Xxx. An example of a method M with
+receiver type T or *T is named ExampleT_M. There may be multiple examples
+for a given function, constant, or variable, distinguished by a trailing _xxx,
+where xxx is a suffix not beginning with an upper case letter.
+
+Here is an example of an example:
+
+.Vb 6
+\& func ExamplePrintln() {
+\& Println("The output of\\nthis example.")
+\& // Output: The output of
+\& // this example.
+\& }
+.Ve
+
+Here is another example where the ordering of the output is ignored:
+
+.Vb 6
+\& func ExamplePerm() {
+\& for _, value := range Perm(4) {
+\& fmt.Println(value)
+\& }
+\&
+\& // Unordered output: 4
+\& // 2
+\& // 1
+\& // 3
+\& // 0
+\& }
+.Ve
+
+The entire test file is presented as the example when it contains a single
+example function, at least one other function, type, variable, or constant
+declaration, and no tests, benchmarks, or fuzz tests.
+
+See the documentation of the testing package for more information.
+.SH AUTHOR
+.PP
+This manual page was written by Michael Stapelberg <stapelberg@debian.org>
+and is maintained by the
+Debian Go Compiler Team <team+go-compiler@tracker.debian.org>
+based on the output of \(oqgo help testfunc\(cq
+for the Debian project (and may be used by others).