@@ -16,34 +16,45 @@ import (
16
16
type defInd = uint32
17
17
18
18
const (
19
- // Production is the best asserter for most uses. The assertion violations
20
- // are treated as Go error values. And only a pragmatic caller info is
21
- // automatically included into the error message like file name, line
22
- // number, and caller function.
19
+ // Production (pkg default) is the best asserter for most uses. The
20
+ // assertion violations are treated as Go error values. And only a
21
+ // pragmatic caller info is automatically included into the error message
22
+ // like file name, line number, and caller function, all in one line:
23
+ //
24
+ // copy file: main.go:37: CopyFile(): assertion violation: string shouldn't be empty
23
25
Production defInd = 0 + iota
24
26
25
27
// Development is the best asserter for most development uses. The
26
28
// assertion violations are treated as Go error values. And a formatted
27
29
// caller info is automatically included to the error message like file
28
- // name, line number, and caller function.
30
+ // name, line number, and caller function. Everything in a beautiful
31
+ // multi-line message:
32
+ //
33
+ // --------------------------------
34
+ // Assertion Fault at:
35
+ // main.go:37 CopyFile():
36
+ // assertion violation: string shouldn't be empty
37
+ // --------------------------------
29
38
Development
30
39
31
40
// Test minimalistic asserter for unit test use. More pragmatic is the
32
- // TestFull asserter (default).
41
+ // TestFull asserter (test default).
33
42
//
34
- // Use this asserter if your IDE/editor doesn't support long file names, or
35
- // for temporary problem solving for your programming environment.
43
+ // Use this asserter if your IDE/editor doesn't support full file names and
44
+ // it relies a relative path (Go standard). You can use this also if you
45
+ // need temporary problem solving for your programming environment.
36
46
Test
37
47
38
- // TestFull asserter (default). The TestFull asserter includes caller info
39
- // and call stack for unit testing, similarly like err2's error traces.
48
+ // TestFull asserter (test default). The TestFull asserter includes the
49
+ // caller info and the call stack for unit testing, similarly like err2's
50
+ // error traces.
40
51
//
41
52
// The call stack produced by the test asserts can be used over Go module
42
53
// boundaries. For example, if your app and it's sub packages both use
43
54
// err2/assert for unit testing and runtime checks, the runtime assertions
44
- // will be automatically converted to test asserts on the fly . If any of
45
- // the runtime asserts in sub packages fails during the app tests, the
46
- // current app test fails too .
55
+ // will be automatically converted to test asserts. If any of the runtime
56
+ // asserts of the sub packages fails during the app tests, the app test
57
+ // fails as well .
47
58
//
48
59
// Note, that the cross-module assertions produce long file names (path
49
60
// included), and some of the Go test result parsers cannot handle that.
@@ -53,7 +64,7 @@ const (
53
64
TestFull
54
65
55
66
// Debug asserter transforms assertion violations to panics which is the
56
- // patter that e.g. Go's standard library uses:
67
+ // pattern that e.g. Go's standard library uses:
57
68
//
58
69
// if p == nil {
59
70
// panic("pkg: ptr cannot be nil")
0 commit comments