Prechádzať zdrojové kódy

Add tests for new ContinueOnMethod option.

Dave Collins 12 rokov pred
rodič
commit
5cc287d265
1 zmenil súbory, kde vykonal 10 pridanie a 0 odobranie
  1. 10 0
      spew/spew_test.go

+ 10 - 0
spew/spew_test.go

@@ -124,6 +124,7 @@ func initSpewTests() {
 	scsNoMethods := &spew.ConfigState{Indent: " ", DisableMethods: true}
 	scsNoPmethods := &spew.ConfigState{Indent: " ", DisablePointerMethods: true}
 	scsMaxDepth := &spew.ConfigState{Indent: " ", MaxDepth: 1}
+	scsContinue := &spew.ConfigState{Indent: " ", ContinueOnMethod: true}
 
 	// Variables for tests on types which implement Stringer interface with and
 	// without a pointer receiver.
@@ -141,6 +142,9 @@ func initSpewTests() {
 	dt := depthTester{indirCir1{nil}, [1]string{"arr"}, []string{"slice"},
 		map[string]int{"one": 1}}
 
+	// Variable for tests on types which implement error interface.
+	te := customError(10)
+
 	spewTests = []spewTest{
 		{scsDefault, fCSFdump, "", int8(127), "(int8) 127\n"},
 		{scsDefault, fCSFprint, "", int16(32767), "32767"},
@@ -175,6 +179,12 @@ func initSpewTests() {
 			" arr: ([1]string) {\n  <max depth reached>\n },\n" +
 			" slice: ([]string) {\n  <max depth reached>\n },\n" +
 			" m: (map[string]int) {\n  <max depth reached>\n }\n}\n"},
+		{scsContinue, fCSFprint, "", ts, "(stringer test) test"},
+		{scsContinue, fCSFdump, "", ts, "(spew_test.stringer) " +
+			"(stringer test) \"test\"\n"},
+		{scsContinue, fCSFprint, "", te, "(error: 10) 10"},
+		{scsContinue, fCSFdump, "", te, "(spew_test.customError) " +
+			"(error: 10) 10\n"},
 	}
 }