Codebase list golang-github-frankban-quicktest / bdd1189
New upstream version 1.13.0 Anthony Fok 2 years ago
7 changed file(s) with 68 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
1010 - "1.13.x"
1111 - "1.14.x"
1212 - "1.15.x"
13 - "1.16.x"
1314 - 1.x
1415 - master
1516
214214 c.Assert(err, qt.IsNil)
215215
216216
217 ### IsNotNil
218
219 IsNotNil is a Checker checking that the provided value is not nil. IsNotNil is
220 the equivalent of qt.Not(qt.IsNil)
221
222 For instance:
223
224 c.Assert(got, qt.IsNotNil)
225
226
217227 ### IsTrue
218228
219229 IsTrue checks that the provided value is true. The value must have a boolean
315315 return errors.New("got non-nil value")
316316 }
317317
318 // IsNotNil is a Checker checking that the provided value is not nil.
319 // IsNotNil is the equivalent of qt.Not(qt.IsNil)
320 //
321 // For instance:
322 //
323 // c.Assert(got, qt.IsNotNil)
324 //
325 var IsNotNil Checker = &notChecker{
326 Checker: IsNil,
327 }
328
318329 // HasLen is a Checker checking that the provided value has the given length.
319330 //
320331 // For instance:
14681468 }
14691469 `,
14701470 }, {
1471 about: "IsNotNil: success",
1472 checker: qt.IsNotNil,
1473 got: 42,
1474 expectedNegateFailure: `
1475 error:
1476 got non-nil value
1477 got:
1478 int(42)
1479 `,
1480 }, {
1481 about: "IsNotNil: failure",
1482 checker: qt.IsNotNil,
1483 got: nil,
1484 expectedCheckFailure: `
1485 error:
1486 unexpected success
1487 got:
1488 nil
1489 `,
1490 }, {
14711491 about: "HasLen: arrays with the same length",
14721492 checker: qt.HasLen,
14731493 got: [4]string{"these", "are", "the", "voyages"},
194194
195195 c.Assert(err, qt.IsNil)
196196
197 IsNotNil
198
199 IsNotNil is a Checker checking that the provided value is not nil.
200 IsNotNil is the equivalent of qt.Not(qt.IsNil)
201
202 For instance:
203
204 c.Assert(got, qt.IsNotNil)
205
197206 IsTrue
198207
199208 IsTrue checks that the provided value is true.
3434 return "s" + quoteString(s)
3535 case string:
3636 return quoteString(v)
37 case uintptr, uint, uint8, uint16, uint32, uint64:
38 // Use decimal base (rather than hexadecimal) for representing uint types.
39 return fmt.Sprintf("%T(%d)", v, v)
3740 }
3841 if bytes, ok := byteSlice(v); ok && bytes != nil && utf8.Valid(bytes) {
3942 // It's a top level slice of bytes that's also valid UTF-8.
107107 about: "struct with byte slice",
108108 value: struct{ X []byte }{[]byte("x")},
109109 want: "struct { X []uint8 }{\n X: {0x78},\n}",
110 }}
110 }, {
111 about: "uint64",
112 value: uint64(17),
113 want: "uint64(17)",
114 }, {
115 about: "uint32",
116 value: uint32(17898),
117 want: "uint32(17898)",
118 }, {
119 about: "uintptr",
120 value: uintptr(13),
121 want: "uintptr(13)",
122 },
123 }
111124
112125 func TestFormat(t *testing.T) {
113126 for _, test := range formatTests {