Debian Codegraph @

comment.go

raw
1 // Licensed under the MIT license, see LICENSE file for details.
2
3 package qt
4
5 import "fmt"
6
7 // Commentf returns a test comment whose output is formatted according to
8 // the given format specifier and args. It may be provided as the last argument
9 // to any check or assertion and will be displayed if the check or assertion
10 // fails.
11 func Commentf(format string, args ...any) Comment {
12 return Comment{
13 format: format,
14 args: args,
15 }
16 }
17
18 // Comment represents additional information on a check or an assertion which is
19 // displayed when the check or assertion fails.
20 type Comment struct {
21 format string
22 args []any
23 }
24
25 // String outputs a string formatted according to the stored format specifier
26 // and args.
27 func (c Comment) String() string {
28 return fmt.Sprintf(c.format, c.args...)
29 }