diff options
| author | Alexander Staubo <[email protected]> | 2016-10-28 13:58:48 -0400 |
|---|---|---|
| committer | Alexander Staubo <[email protected]> | 2016-10-28 13:58:48 -0400 |
| commit | 04cdfd42973bb9c8589fd6a731800cf222fde1a9 (patch) | |
| tree | 4ba146e17ec66bfd2858c788972ecaf45cf6e56d /spew/spew_test.go | |
| parent | 6d212800a42e8ab5c146b8ace3490ee17e5225f9 (diff) | |
Adds new config options:
DisablePointerAddresses: Specifies whether to disable the printing of
pointer addresses.
DisableCapacities specifies whether to disable the printing of capacities
for arrays, slices, maps and channels.
These are useful when diffing data structures in tests. Printing pointers
and capacities would otherwise lead to false negatives.
Diffstat (limited to 'spew/spew_test.go')
| -rw-r--r-- | spew/spew_test.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/spew/spew_test.go b/spew/spew_test.go index dbbc085..f1f6b71 100644 --- a/spew/spew_test.go +++ b/spew/spew_test.go @@ -130,12 +130,19 @@ func initSpewTests() { scsNoPmethods := &spew.ConfigState{Indent: " ", DisablePointerMethods: true} scsMaxDepth := &spew.ConfigState{Indent: " ", MaxDepth: 1} scsContinue := &spew.ConfigState{Indent: " ", ContinueOnMethod: true} + scsNoPtrAddr := &spew.ConfigState{DisablePointerAddresses: true} + scsNoCap := &spew.ConfigState{DisableCapacities: true} // Variables for tests on types which implement Stringer interface with and // without a pointer receiver. ts := stringer("test") tps := pstringer("test") + type ptrTester struct { + s *struct{} + } + tptr := &ptrTester{s: &struct{}{}} + // depthTester is used to test max depth handling for structs, array, slices // and maps. type depthTester struct { @@ -192,6 +199,10 @@ func initSpewTests() { {scsContinue, fCSFprint, "", te, "(error: 10) 10"}, {scsContinue, fCSFdump, "", te, "(spew_test.customError) " + "(error: 10) 10\n"}, + {scsNoPtrAddr, fCSFprint, "", tptr, "<*>{<*>{}}"}, + {scsNoPtrAddr, fCSSdump, "", tptr, "(*spew_test.ptrTester)({\ns: (*struct {})({\n})\n})\n"}, + {scsNoCap, fCSSdump, "", make([]string, 0, 10), "([]string) {\n}\n"}, + {scsNoCap, fCSSdump, "", make([]string, 1, 10), "([]string) (len=1) {\n(string) \"\"\n}\n"}, } } |
