| 1 | // These tests verify the inner workings of the helper methods associated |
| 2 | // with check.T. |
| 3 | |
| 4 | package check_testscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/ |
| 5 | |
| 6 | import ( |
| 7 | "osscip-go gomod github.com/golang/go/src go1.13 os/" |
| 8 | "reflectscip-go gomod github.com/golang/go/src go1.13 reflect/" |
| 9 | "runtimescip-go gomod github.com/golang/go/src go1.13 runtime/" |
| 10 | "syncscip-go gomod github.com/golang/go/src go1.13 sync/" |
| 11 | |
| 12 | "github.com/pingcap/checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/" |
| 13 | ) |
| 14 | |
| 15 | var helpersSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/helpersS. = checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Suitescip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/Suite().(&HelpersSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#{}) |
| 16 | |
| 17 | type HelpersSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS# struct{} |
| 18 | |
| 19 | func (s *HelpersSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#) TestCountSuitescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#TestCountSuite().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 20 | suitesRunscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/suitesRun. += 1 |
| 21 | } |
| 22 | |
| 23 | // ----------------------------------------------------------------------- |
| 24 | // Fake checker and bug info to verify the behavior of Assert() and Check(). |
| 25 | |
| 26 | type MyCheckerscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker# struct { |
| 27 | infoscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#info. *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.CheckerInfoscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/CheckerInfo# |
| 28 | paramsscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#params. []interface{} |
| 29 | namesscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#names. []string |
| 30 | resultscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#result. bool |
| 31 | errorscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#error. string |
| 32 | } |
| 33 | |
| 34 | func (checker *MyCheckerscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#) Infoscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#Info().() *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.CheckerInfoscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/CheckerInfo# { |
| 35 | if checker.infoscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#info. == nil { |
| 36 | return &checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.CheckerInfoscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/CheckerInfo#{Namescip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/CheckerInfo#Name.: "MyChecker", Paramsscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/CheckerInfo#Params.: []string{"myobtained", "myexpected"}} |
| 37 | } |
| 38 | return checker.infoscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#info. |
| 39 | } |
| 40 | |
| 41 | func (checker *MyCheckerscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#) Checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#Check().(params []interface{}, names []string) (bool, string) { |
| 42 | rparams := checker.paramsscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#params. |
| 43 | rnames := checker.namesscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#names. |
| 44 | checker.paramsscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#params. = append([]interface{}{}, params...) |
| 45 | checker.namesscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#names. = append([]string{}, names...) |
| 46 | if rparams != nil { |
| 47 | copy(params, rparams) |
| 48 | } |
| 49 | if rnames != nil { |
| 50 | copy(names, rnames) |
| 51 | } |
| 52 | return checker.resultscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#result., checker.errorscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#error. |
| 53 | } |
| 54 | |
| 55 | type myCommentTypescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/myCommentType# string |
| 56 | |
| 57 | func (c myCommentTypescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/myCommentType#) CheckCommentStringscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/myCommentType#CheckCommentString().() string { |
| 58 | return string(c) |
| 59 | } |
| 60 | |
| 61 | func myCommentscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/myComment().(s string) myCommentTypescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/myCommentType# { |
| 62 | return myCommentTypescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/myCommentType#(s) |
| 63 | } |
| 64 | |
| 65 | // ----------------------------------------------------------------------- |
| 66 | // Ensure a real checker actually works fine. |
| 67 | |
| 68 | func (s *HelpersSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#) TestCheckerInterfacescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#TestCheckerInterface().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 69 | testHelperSuccessscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/testHelperSuccess().(c, "Check(1, Equals, 1)", true, func() interface{} { |
| 70 | return c.Checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Check().(1, checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Equalsscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/Equals., 1) |
| 71 | }) |
| 72 | } |
| 73 | |
| 74 | // ----------------------------------------------------------------------- |
| 75 | // Tests for Check(), mostly the same as for Assert() following these. |
| 76 | |
| 77 | func (s *HelpersSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#) TestCheckSucceedWithExpectedscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#TestCheckSucceedWithExpected().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 78 | checker := &MyCheckerscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#{resultscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#result.: true} |
| 79 | testHelperSuccessscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/testHelperSuccess().(c, "Check(1, checker, 2)", true, func() interface{} { |
| 80 | return c.Checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Check().(1, checker, 2) |
| 81 | }) |
| 82 | if !reflectscip-go gomod github.com/golang/go/src go1.13 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.13 reflect/DeepEqual().(checker.paramsscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#params., []interface{}{1, 2}) { |
| 83 | c.Fatalfscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Fatalf().("Bad params for check: %#v", checker.paramsscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#params.) |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | func (s *HelpersSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#) TestCheckSucceedWithoutExpectedscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#TestCheckSucceedWithoutExpected().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 88 | checker := &MyCheckerscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#{resultscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#result.: true, infoscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#info.: &checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.CheckerInfoscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/CheckerInfo#{Paramsscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/CheckerInfo#Params.: []string{"myvalue"}}} |
| 89 | testHelperSuccessscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/testHelperSuccess().(c, "Check(1, checker)", true, func() interface{} { |
| 90 | return c.Checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Check().(1, checker) |
| 91 | }) |
| 92 | if !reflectscip-go gomod github.com/golang/go/src go1.13 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.13 reflect/DeepEqual().(checker.paramsscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#params., []interface{}{1}) { |
| 93 | c.Fatalfscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Fatalf().("Bad params for check: %#v", checker.paramsscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#params.) |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | func (s *HelpersSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#) TestCheckFailWithExpectedscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#TestCheckFailWithExpected().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 98 | checker := &MyCheckerscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#{resultscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#result.: false} |
| 99 | log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + |
| 100 | " return c\\.Check\\(1, checker, 2\\)\n" + |
| 101 | "\\.+ myobtained int = 1\n" + |
| 102 | "\\.+ myexpected int = 2\n\n" |
| 103 | testHelperFailurescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/testHelperFailure().(c, "Check(1, checker, 2)", false, false, log, |
| 104 | func() interface{} { |
| 105 | return c.Checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Check().(1, checker, 2) |
| 106 | }) |
| 107 | } |
| 108 | |
| 109 | func (s *HelpersSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#) TestCheckFailWithExpectedAndCommentscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#TestCheckFailWithExpectedAndComment().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 110 | checker := &MyCheckerscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#{resultscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#result.: false} |
| 111 | log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + |
| 112 | " return c\\.Check\\(1, checker, 2, myComment\\(\"Hello world!\"\\)\\)\n" + |
| 113 | "\\.+ myobtained int = 1\n" + |
| 114 | "\\.+ myexpected int = 2\n" + |
| 115 | "\\.+ Hello world!\n\n" |
| 116 | testHelperFailurescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/testHelperFailure().(c, "Check(1, checker, 2, msg)", false, false, log, |
| 117 | func() interface{} { |
| 118 | return c.Checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Check().(1, checker, 2, myCommentscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/myComment().("Hello world!")) |
| 119 | }) |
| 120 | } |
| 121 | |
| 122 | func (s *HelpersSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#) TestCheckFailWithExpectedAndStaticCommentscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#TestCheckFailWithExpectedAndStaticComment().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 123 | checker := &MyCheckerscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#{resultscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#result.: false} |
| 124 | log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + |
| 125 | " // Nice leading comment\\.\n" + |
| 126 | " return c\\.Check\\(1, checker, 2\\) // Hello there\n" + |
| 127 | "\\.+ myobtained int = 1\n" + |
| 128 | "\\.+ myexpected int = 2\n\n" |
| 129 | testHelperFailurescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/testHelperFailure().(c, "Check(1, checker, 2, msg)", false, false, log, |
| 130 | func() interface{} { |
| 131 | // Nice leading comment. |
| 132 | return c.Checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Check().(1, checker, 2) // Hello there |
| 133 | }) |
| 134 | } |
| 135 | |
| 136 | func (s *HelpersSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#) TestCheckFailWithoutExpectedscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#TestCheckFailWithoutExpected().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 137 | checker := &MyCheckerscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#{resultscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#result.: false, infoscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#info.: &checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.CheckerInfoscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/CheckerInfo#{Paramsscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/CheckerInfo#Params.: []string{"myvalue"}}} |
| 138 | log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + |
| 139 | " return c\\.Check\\(1, checker\\)\n" + |
| 140 | "\\.+ myvalue int = 1\n\n" |
| 141 | testHelperFailurescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/testHelperFailure().(c, "Check(1, checker)", false, false, log, |
| 142 | func() interface{} { |
| 143 | return c.Checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Check().(1, checker) |
| 144 | }) |
| 145 | } |
| 146 | |
| 147 | func (s *HelpersSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#) TestCheckFailWithoutExpectedAndMessagescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#TestCheckFailWithoutExpectedAndMessage().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 148 | checker := &MyCheckerscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#{resultscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#result.: false, infoscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#info.: &checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.CheckerInfoscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/CheckerInfo#{Paramsscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/CheckerInfo#Params.: []string{"myvalue"}}} |
| 149 | log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + |
| 150 | " return c\\.Check\\(1, checker, myComment\\(\"Hello world!\"\\)\\)\n" + |
| 151 | "\\.+ myvalue int = 1\n" + |
| 152 | "\\.+ Hello world!\n\n" |
| 153 | testHelperFailurescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/testHelperFailure().(c, "Check(1, checker, msg)", false, false, log, |
| 154 | func() interface{} { |
| 155 | return c.Checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Check().(1, checker, myCommentscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/myComment().("Hello world!")) |
| 156 | }) |
| 157 | } |
| 158 | |
| 159 | func (s *HelpersSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#) TestCheckWithMissingExpectedscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#TestCheckWithMissingExpected().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 160 | checker := &MyCheckerscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#{resultscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#result.: true} |
| 161 | log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + |
| 162 | " return c\\.Check\\(1, checker\\)\n" + |
| 163 | "\\.+ Check\\(myobtained, MyChecker, myexpected\\):\n" + |
| 164 | "\\.+ Wrong number of parameters for MyChecker: " + |
| 165 | "want 3, got 2\n\n" |
| 166 | testHelperFailurescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/testHelperFailure().(c, "Check(1, checker, !?)", false, false, log, |
| 167 | func() interface{} { |
| 168 | return c.Checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Check().(1, checker) |
| 169 | }) |
| 170 | } |
| 171 | |
| 172 | func (s *HelpersSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#) TestCheckWithTooManyExpectedscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#TestCheckWithTooManyExpected().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 173 | checker := &MyCheckerscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#{resultscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#result.: true} |
| 174 | log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + |
| 175 | " return c\\.Check\\(1, checker, 2, 3\\)\n" + |
| 176 | "\\.+ Check\\(myobtained, MyChecker, myexpected\\):\n" + |
| 177 | "\\.+ Wrong number of parameters for MyChecker: " + |
| 178 | "want 3, got 4\n\n" |
| 179 | testHelperFailurescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/testHelperFailure().(c, "Check(1, checker, 2, 3)", false, false, log, |
| 180 | func() interface{} { |
| 181 | return c.Checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Check().(1, checker, 2, 3) |
| 182 | }) |
| 183 | } |
| 184 | |
| 185 | func (s *HelpersSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#) TestCheckWithErrorscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#TestCheckWithError().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 186 | checker := &MyCheckerscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#{resultscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#result.: false, errorscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#error.: "Some not so cool data provided!"} |
| 187 | log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + |
| 188 | " return c\\.Check\\(1, checker, 2\\)\n" + |
| 189 | "\\.+ myobtained int = 1\n" + |
| 190 | "\\.+ myexpected int = 2\n" + |
| 191 | "\\.+ Some not so cool data provided!\n\n" |
| 192 | testHelperFailurescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/testHelperFailure().(c, "Check(1, checker, 2)", false, false, log, |
| 193 | func() interface{} { |
| 194 | return c.Checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Check().(1, checker, 2) |
| 195 | }) |
| 196 | } |
| 197 | |
| 198 | func (s *HelpersSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#) TestCheckWithNilCheckerscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#TestCheckWithNilChecker().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 199 | log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + |
| 200 | " return c\\.Check\\(1, nil\\)\n" + |
| 201 | "\\.+ Check\\(obtained, nil!\\?, \\.\\.\\.\\):\n" + |
| 202 | "\\.+ Oops\\.\\. you've provided a nil checker!\n\n" |
| 203 | testHelperFailurescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/testHelperFailure().(c, "Check(obtained, nil)", false, false, log, |
| 204 | func() interface{} { |
| 205 | return c.Checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Check().(1, nil) |
| 206 | }) |
| 207 | } |
| 208 | |
| 209 | func (s *HelpersSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#) TestCheckWithParamsAndNamesMutationscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#TestCheckWithParamsAndNamesMutation().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 210 | checker := &MyCheckerscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#{resultscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#result.: false, paramsscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#params.: []interface{}{3, 4}, namesscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#names.: []string{"newobtained", "newexpected"}} |
| 211 | log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + |
| 212 | " return c\\.Check\\(1, checker, 2\\)\n" + |
| 213 | "\\.+ newobtained int = 3\n" + |
| 214 | "\\.+ newexpected int = 4\n\n" |
| 215 | testHelperFailurescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/testHelperFailure().(c, "Check(1, checker, 2) with mutation", false, false, log, |
| 216 | func() interface{} { |
| 217 | return c.Checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Check().(1, checker, 2) |
| 218 | }) |
| 219 | } |
| 220 | |
| 221 | // ----------------------------------------------------------------------- |
| 222 | // Tests for Assert(), mostly the same as for Check() above. |
| 223 | |
| 224 | func (s *HelpersSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#) TestAssertSucceedWithExpectedscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#TestAssertSucceedWithExpected().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 225 | checker := &MyCheckerscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#{resultscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#result.: true} |
| 226 | testHelperSuccessscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/testHelperSuccess().(c, "Assert(1, checker, 2)", nil, func() interface{} { |
| 227 | c.Assertscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Assert().(1, checker, 2) |
| 228 | return nil |
| 229 | }) |
| 230 | if !reflectscip-go gomod github.com/golang/go/src go1.13 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.13 reflect/DeepEqual().(checker.paramsscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#params., []interface{}{1, 2}) { |
| 231 | c.Fatalfscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Fatalf().("Bad params for check: %#v", checker.paramsscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#params.) |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | func (s *HelpersSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#) TestAssertSucceedWithoutExpectedscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#TestAssertSucceedWithoutExpected().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 236 | checker := &MyCheckerscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#{resultscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#result.: true, infoscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#info.: &checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.CheckerInfoscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/CheckerInfo#{Paramsscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/CheckerInfo#Params.: []string{"myvalue"}}} |
| 237 | testHelperSuccessscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/testHelperSuccess().(c, "Assert(1, checker)", nil, func() interface{} { |
| 238 | c.Assertscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Assert().(1, checker) |
| 239 | return nil |
| 240 | }) |
| 241 | if !reflectscip-go gomod github.com/golang/go/src go1.13 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.13 reflect/DeepEqual().(checker.paramsscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#params., []interface{}{1}) { |
| 242 | c.Fatalfscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Fatalf().("Bad params for check: %#v", checker.paramsscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#params.) |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | func (s *HelpersSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#) TestAssertFailWithExpectedscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#TestAssertFailWithExpected().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 247 | checker := &MyCheckerscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#{resultscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#result.: false} |
| 248 | log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + |
| 249 | " c\\.Assert\\(1, checker, 2\\)\n" + |
| 250 | "\\.+ myobtained int = 1\n" + |
| 251 | "\\.+ myexpected int = 2\n\n" |
| 252 | testHelperFailurescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/testHelperFailure().(c, "Assert(1, checker, 2)", nil, true, log, |
| 253 | func() interface{} { |
| 254 | c.Assertscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Assert().(1, checker, 2) |
| 255 | return nil |
| 256 | }) |
| 257 | } |
| 258 | |
| 259 | func (s *HelpersSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#) TestAssertFailWithExpectedAndMessagescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#TestAssertFailWithExpectedAndMessage().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 260 | checker := &MyCheckerscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#{resultscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#result.: false} |
| 261 | log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + |
| 262 | " c\\.Assert\\(1, checker, 2, myComment\\(\"Hello world!\"\\)\\)\n" + |
| 263 | "\\.+ myobtained int = 1\n" + |
| 264 | "\\.+ myexpected int = 2\n" + |
| 265 | "\\.+ Hello world!\n\n" |
| 266 | testHelperFailurescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/testHelperFailure().(c, "Assert(1, checker, 2, msg)", nil, true, log, |
| 267 | func() interface{} { |
| 268 | c.Assertscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Assert().(1, checker, 2, myCommentscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/myComment().("Hello world!")) |
| 269 | return nil |
| 270 | }) |
| 271 | } |
| 272 | |
| 273 | func (s *HelpersSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#) TestAssertFailWithoutExpectedscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#TestAssertFailWithoutExpected().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 274 | checker := &MyCheckerscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#{resultscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#result.: false, infoscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#info.: &checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.CheckerInfoscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/CheckerInfo#{Paramsscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/CheckerInfo#Params.: []string{"myvalue"}}} |
| 275 | log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + |
| 276 | " c\\.Assert\\(1, checker\\)\n" + |
| 277 | "\\.+ myvalue int = 1\n\n" |
| 278 | testHelperFailurescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/testHelperFailure().(c, "Assert(1, checker)", nil, true, log, |
| 279 | func() interface{} { |
| 280 | c.Assertscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Assert().(1, checker) |
| 281 | return nil |
| 282 | }) |
| 283 | } |
| 284 | |
| 285 | func (s *HelpersSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#) TestAssertFailWithoutExpectedAndMessagescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#TestAssertFailWithoutExpectedAndMessage().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 286 | checker := &MyCheckerscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#{resultscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#result.: false, infoscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#info.: &checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.CheckerInfoscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/CheckerInfo#{Paramsscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/CheckerInfo#Params.: []string{"myvalue"}}} |
| 287 | log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + |
| 288 | " c\\.Assert\\(1, checker, myComment\\(\"Hello world!\"\\)\\)\n" + |
| 289 | "\\.+ myvalue int = 1\n" + |
| 290 | "\\.+ Hello world!\n\n" |
| 291 | testHelperFailurescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/testHelperFailure().(c, "Assert(1, checker, msg)", nil, true, log, |
| 292 | func() interface{} { |
| 293 | c.Assertscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Assert().(1, checker, myCommentscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/myComment().("Hello world!")) |
| 294 | return nil |
| 295 | }) |
| 296 | } |
| 297 | |
| 298 | func (s *HelpersSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#) TestAssertWithMissingExpectedscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#TestAssertWithMissingExpected().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 299 | checker := &MyCheckerscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#{resultscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#result.: true} |
| 300 | log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + |
| 301 | " c\\.Assert\\(1, checker\\)\n" + |
| 302 | "\\.+ Assert\\(myobtained, MyChecker, myexpected\\):\n" + |
| 303 | "\\.+ Wrong number of parameters for MyChecker: " + |
| 304 | "want 3, got 2\n\n" |
| 305 | testHelperFailurescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/testHelperFailure().(c, "Assert(1, checker, !?)", nil, true, log, |
| 306 | func() interface{} { |
| 307 | c.Assertscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Assert().(1, checker) |
| 308 | return nil |
| 309 | }) |
| 310 | } |
| 311 | |
| 312 | func (s *HelpersSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#) TestAssertWithErrorscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#TestAssertWithError().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 313 | checker := &MyCheckerscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#{resultscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#result.: false, errorscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#error.: "Some not so cool data provided!"} |
| 314 | log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + |
| 315 | " c\\.Assert\\(1, checker, 2\\)\n" + |
| 316 | "\\.+ myobtained int = 1\n" + |
| 317 | "\\.+ myexpected int = 2\n" + |
| 318 | "\\.+ Some not so cool data provided!\n\n" |
| 319 | testHelperFailurescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/testHelperFailure().(c, "Assert(1, checker, 2)", nil, true, log, |
| 320 | func() interface{} { |
| 321 | c.Assertscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Assert().(1, checker, 2) |
| 322 | return nil |
| 323 | }) |
| 324 | } |
| 325 | |
| 326 | func (s *HelpersSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#) TestAssertWithNilCheckerscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#TestAssertWithNilChecker().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 327 | log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + |
| 328 | " c\\.Assert\\(1, nil\\)\n" + |
| 329 | "\\.+ Assert\\(obtained, nil!\\?, \\.\\.\\.\\):\n" + |
| 330 | "\\.+ Oops\\.\\. you've provided a nil checker!\n\n" |
| 331 | testHelperFailurescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/testHelperFailure().(c, "Assert(obtained, nil)", nil, true, log, |
| 332 | func() interface{} { |
| 333 | c.Assertscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Assert().(1, nil) |
| 334 | return nil |
| 335 | }) |
| 336 | } |
| 337 | |
| 338 | // ----------------------------------------------------------------------- |
| 339 | // Ensure that values logged work properly in some interesting cases. |
| 340 | |
| 341 | func (s *HelpersSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#) TestValueLoggingWithArraysscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#TestValueLoggingWithArrays().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 342 | checker := &MyCheckerscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#{resultscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#result.: false} |
| 343 | log := "(?s)helpers_test.go:[0-9]+:.*\nhelpers_test.go:[0-9]+:\n" + |
| 344 | " return c\\.Check\\(\\[\\]byte{1, 2}, checker, \\[\\]byte{1, 3}\\)\n" + |
| 345 | "\\.+ myobtained \\[\\]uint8 = \\[\\]byte{0x1, 0x2}\n" + |
| 346 | "\\.+ myexpected \\[\\]uint8 = \\[\\]byte{0x1, 0x3}\n\n" |
| 347 | testHelperFailurescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/testHelperFailure().(c, "Check([]byte{1}, chk, []byte{3})", false, false, log, |
| 348 | func() interface{} { |
| 349 | return c.Checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Check().([]byte{1, 2}, checker, []byte{1, 3}) |
| 350 | }) |
| 351 | } |
| 352 | |
| 353 | func (s *HelpersSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#) TestValueLoggingWithMultiLinescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#TestValueLoggingWithMultiLine().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 354 | checker := &MyCheckerscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#{resultscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#result.: false} |
| 355 | log := "(?s)helpers_test.go:[0-9]+:.*\nhelpers_test.go:[0-9]+:\n" + |
| 356 | " return c\\.Check\\(\"a\\\\nb\\\\n\", checker, \"a\\\\nb\\\\nc\"\\)\n" + |
| 357 | "\\.+ myobtained string = \"\" \\+\n" + |
| 358 | "\\.+ \"a\\\\n\" \\+\n" + |
| 359 | "\\.+ \"b\\\\n\"\n" + |
| 360 | "\\.+ myexpected string = \"\" \\+\n" + |
| 361 | "\\.+ \"a\\\\n\" \\+\n" + |
| 362 | "\\.+ \"b\\\\n\" \\+\n" + |
| 363 | "\\.+ \"c\"\n\n" |
| 364 | testHelperFailurescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/testHelperFailure().(c, `Check("a\nb\n", chk, "a\nb\nc")`, false, false, log, |
| 365 | func() interface{} { |
| 366 | return c.Checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Check().("a\nb\n", checker, "a\nb\nc") |
| 367 | }) |
| 368 | } |
| 369 | |
| 370 | func (s *HelpersSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#) TestValueLoggingWithMultiLineExceptionscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#TestValueLoggingWithMultiLineException().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 371 | // If the newline is at the end of the string, don't log as multi-line. |
| 372 | checker := &MyCheckerscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#{resultscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MyChecker#result.: false} |
| 373 | log := "(?s)helpers_test.go:[0-9]+:.*\nhelpers_test.go:[0-9]+:\n" + |
| 374 | " return c\\.Check\\(\"a b\\\\n\", checker, \"a\\\\nb\"\\)\n" + |
| 375 | "\\.+ myobtained string = \"a b\\\\n\"\n" + |
| 376 | "\\.+ myexpected string = \"\" \\+\n" + |
| 377 | "\\.+ \"a\\\\n\" \\+\n" + |
| 378 | "\\.+ \"b\"\n\n" |
| 379 | testHelperFailurescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/testHelperFailure().(c, `Check("a b\n", chk, "a\nb")`, false, false, log, |
| 380 | func() interface{} { |
| 381 | return c.Checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Check().("a b\n", checker, "a\nb") |
| 382 | }) |
| 383 | } |
| 384 | |
| 385 | // ----------------------------------------------------------------------- |
| 386 | // MakeDir() tests. |
| 387 | |
| 388 | type MkDirHelperscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MkDirHelper# struct { |
| 389 | path1scip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MkDirHelper#path1. string |
| 390 | path2scip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MkDirHelper#path2. string |
| 391 | isDir1scip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MkDirHelper#isDir1. bool |
| 392 | isDir2scip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MkDirHelper#isDir2. bool |
| 393 | isDir3scip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MkDirHelper#isDir3. bool |
| 394 | isDir4scip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MkDirHelper#isDir4. bool |
| 395 | } |
| 396 | |
| 397 | func (s *MkDirHelperscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MkDirHelper#) SetUpSuitescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MkDirHelper#SetUpSuite().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 398 | s.path1scip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MkDirHelper#path1. = c.MkDirscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#MkDir().() |
| 399 | s.isDir1scip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MkDirHelper#isDir1. = isDirscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/isDir().(s.path1scip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MkDirHelper#path1.) |
| 400 | } |
| 401 | |
| 402 | func (s *MkDirHelperscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MkDirHelper#) Testscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MkDirHelper#Test().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 403 | s.path2scip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MkDirHelper#path2. = c.MkDirscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#MkDir().() |
| 404 | s.isDir2scip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MkDirHelper#isDir2. = isDirscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/isDir().(s.path2scip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MkDirHelper#path2.) |
| 405 | } |
| 406 | |
| 407 | func (s *MkDirHelperscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MkDirHelper#) TearDownSuitescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MkDirHelper#TearDownSuite().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 408 | s.isDir3scip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MkDirHelper#isDir3. = isDirscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/isDir().(s.path1scip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MkDirHelper#path1.) |
| 409 | s.isDir4scip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MkDirHelper#isDir4. = isDirscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/isDir().(s.path2scip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MkDirHelper#path2.) |
| 410 | } |
| 411 | |
| 412 | func (s *HelpersSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#) TestMkDirscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#TestMkDir().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 413 | helper := MkDirHelperscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MkDirHelper#{} |
| 414 | output := Stringscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/String#{} |
| 415 | checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Runscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/Run().(&helper, &checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.RunConfscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/RunConf#{Outputscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/RunConf#Output.: &output}) |
| 416 | c.Assertscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Assert().(output.valuescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/String#value., checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Equalsscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/Equals., "") |
| 417 | c.Checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Check().(helper.isDir1scip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MkDirHelper#isDir1., checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Equalsscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/Equals., true) |
| 418 | c.Checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Check().(helper.isDir2scip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MkDirHelper#isDir2., checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Equalsscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/Equals., true) |
| 419 | c.Checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Check().(helper.isDir3scip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MkDirHelper#isDir3., checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Equalsscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/Equals., true) |
| 420 | c.Checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Check().(helper.isDir4scip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MkDirHelper#isDir4., checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Equalsscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/Equals., true) |
| 421 | c.Checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Check().(helper.path1scip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MkDirHelper#path1., checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Notscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/Not().(checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Equalsscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/Equals.), |
| 422 | helper.path2scip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MkDirHelper#path2.) |
| 423 | c.Checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Check().(isDirscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/isDir().(helper.path1scip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MkDirHelper#path1.), checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Equalsscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/Equals., false) |
| 424 | c.Checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Check().(isDirscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/isDir().(helper.path2scip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/MkDirHelper#path2.), checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Equalsscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/Equals., false) |
| 425 | } |
| 426 | |
| 427 | func isDirscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/isDir().(path string) bool { |
| 428 | if stat, err := osscip-go gomod github.com/golang/go/src go1.13 os/.Statscip-go gomod github.com/golang/go/src go1.13 os/Stat().(path); err == nil { |
| 429 | return stat.IsDirscip-go gomod github.com/golang/go/src go1.13 `io/fs`/FileInfo#IsDir().() |
| 430 | } |
| 431 | return false |
| 432 | } |
| 433 | |
| 434 | // Concurrent logging should not corrupt the underling buffer. |
| 435 | // Use go test -race to detect the race in this test. |
| 436 | func (s *HelpersSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#) TestConcurrentLoggingscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#TestConcurrentLogging().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 437 | defer runtimescip-go gomod github.com/golang/go/src go1.13 runtime/.GOMAXPROCSscip-go gomod github.com/golang/go/src go1.13 runtime/GOMAXPROCS().(runtimescip-go gomod github.com/golang/go/src go1.13 runtime/.GOMAXPROCSscip-go gomod github.com/golang/go/src go1.13 runtime/GOMAXPROCS().(runtimescip-go gomod github.com/golang/go/src go1.13 runtime/.NumCPUscip-go gomod github.com/golang/go/src go1.13 runtime/NumCPU().())) |
| 438 | var start, stop syncscip-go gomod github.com/golang/go/src go1.13 sync/.WaitGroupscip-go gomod github.com/golang/go/src go1.13 sync/WaitGroup# |
| 439 | start.Addscip-go gomod github.com/golang/go/src go1.13 sync/WaitGroup#Add().(1) |
| 440 | for i, n := 0, runtimescip-go gomod github.com/golang/go/src go1.13 runtime/.NumCPUscip-go gomod github.com/golang/go/src go1.13 runtime/NumCPU().()*2; i < n; i++ { |
| 441 | stop.Addscip-go gomod github.com/golang/go/src go1.13 sync/WaitGroup#Add().(1) |
| 442 | go func(i int) { |
| 443 | start.Waitscip-go gomod github.com/golang/go/src go1.13 sync/WaitGroup#Wait().() |
| 444 | for j := 0; j < 30; j++ { |
| 445 | c.Logfscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Logf().("Worker %d: line %d", i, j) |
| 446 | } |
| 447 | stop.Donescip-go gomod github.com/golang/go/src go1.13 sync/WaitGroup#Done().() |
| 448 | }(i) |
| 449 | } |
| 450 | start.Donescip-go gomod github.com/golang/go/src go1.13 sync/WaitGroup#Done().() |
| 451 | stop.Waitscip-go gomod github.com/golang/go/src go1.13 sync/WaitGroup#Wait().() |
| 452 | } |
| 453 | |
| 454 | // ----------------------------------------------------------------------- |
| 455 | // Test the TestName function |
| 456 | |
| 457 | type TestNameHelperscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/TestNameHelper# struct { |
| 458 | name1scip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/TestNameHelper#name1. string |
| 459 | name2scip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/TestNameHelper#name2. string |
| 460 | name3scip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/TestNameHelper#name3. string |
| 461 | name4scip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/TestNameHelper#name4. string |
| 462 | name5scip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/TestNameHelper#name5. string |
| 463 | } |
| 464 | |
| 465 | func (s *TestNameHelperscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/TestNameHelper#) SetUpSuitescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/TestNameHelper#SetUpSuite().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { s.name1scip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/TestNameHelper#name1. = c.TestNamescip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#TestName().() } |
| 466 | func (s *TestNameHelperscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/TestNameHelper#) SetUpTestscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/TestNameHelper#SetUpTest().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { s.name2scip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/TestNameHelper#name2. = c.TestNamescip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#TestName().() } |
| 467 | func (s *TestNameHelperscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/TestNameHelper#) Testscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/TestNameHelper#Test().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { s.name3scip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/TestNameHelper#name3. = c.TestNamescip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#TestName().() } |
| 468 | func (s *TestNameHelperscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/TestNameHelper#) TearDownTestscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/TestNameHelper#TearDownTest().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { s.name4scip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/TestNameHelper#name4. = c.TestNamescip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#TestName().() } |
| 469 | func (s *TestNameHelperscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/TestNameHelper#) TearDownSuitescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/TestNameHelper#TearDownSuite().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { s.name5scip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/TestNameHelper#name5. = c.TestNamescip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#TestName().() } |
| 470 | |
| 471 | func (s *HelpersSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#) TestTestNamescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/HelpersS#TestTestName().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 472 | helper := TestNameHelperscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/TestNameHelper#{} |
| 473 | output := Stringscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/String#{} |
| 474 | checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Runscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/Run().(&helper, &checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.RunConfscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/RunConf#{Outputscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/RunConf#Output.: &output}) |
| 475 | c.Checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Check().(helper.name1scip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/TestNameHelper#name1., checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Equalsscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/Equals., "") |
| 476 | c.Checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Check().(helper.name2scip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/TestNameHelper#name2., checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Equalsscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/Equals., "TestNameHelper.Test") |
| 477 | c.Checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Check().(helper.name3scip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/TestNameHelper#name3., checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Equalsscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/Equals., "TestNameHelper.Test") |
| 478 | c.Checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Check().(helper.name4scip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/TestNameHelper#name4., checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Equalsscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/Equals., "TestNameHelper.Test") |
| 479 | c.Checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Check().(helper.name5scip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/TestNameHelper#name5., checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Equalsscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/Equals., "") |
| 480 | } |
| 481 | |
| 482 | // ----------------------------------------------------------------------- |
| 483 | // A couple of helper functions to test helper functions. :-) |
| 484 | |
| 485 | func testHelperSuccessscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/testHelperSuccess().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#, name string, expectedResult interface{}, closure func() interface{}) { |
| 486 | var result interface{} |
| 487 | defer (func() { |
| 488 | if err := recover(); err != nil { |
| 489 | panic(err) |
| 490 | } |
| 491 | checkStatescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/checkState().(c, result, |
| 492 | &expectedStatescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/expectedState#{ |
| 493 | namescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/expectedState#name.: name, |
| 494 | resultscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/expectedState#result.: expectedResult, |
| 495 | failedscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/expectedState#failed.: false, |
| 496 | logscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/expectedState#log.: "", |
| 497 | }) |
| 498 | })() |
| 499 | result = closure() |
| 500 | } |
| 501 | |
| 502 | func testHelperFailurescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/testHelperFailure().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#, name string, expectedResult interface{}, shouldStop bool, log string, closure func() interface{}) { |
| 503 | var result interface{} |
| 504 | defer (func() { |
| 505 | if err := recover(); err != nil { |
| 506 | panic(err) |
| 507 | } |
| 508 | checkStatescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/checkState().(c, result, |
| 509 | &expectedStatescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/expectedState#{ |
| 510 | namescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/expectedState#name.: name, |
| 511 | resultscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/expectedState#result.: expectedResult, |
| 512 | failedscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/expectedState#failed.: true, |
| 513 | logscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/expectedState#log.: log, |
| 514 | }) |
| 515 | })() |
| 516 | result = closure() |
| 517 | if shouldStop { |
| 518 | c.Logfscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Logf().("%s didn't stop when it should", name) |
| 519 | } |
| 520 | } |