New upstream version 1.13.0
Anthony Fok
2 years ago
214 | 214 |
c.Assert(err, qt.IsNil)
|
215 | 215 |
|
216 | 216 |
|
|
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 |
|
217 | 227 |
### IsTrue
|
218 | 228 |
|
219 | 229 |
IsTrue checks that the provided value is true. The value must have a boolean
|
315 | 315 |
return errors.New("got non-nil value")
|
316 | 316 |
}
|
317 | 317 |
|
|
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 = ¬Checker{
|
|
326 |
Checker: IsNil,
|
|
327 |
}
|
|
328 |
|
318 | 329 |
// HasLen is a Checker checking that the provided value has the given length.
|
319 | 330 |
//
|
320 | 331 |
// For instance:
|
1468 | 1468 |
}
|
1469 | 1469 |
`,
|
1470 | 1470 |
}, {
|
|
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 |
}, {
|
1471 | 1491 |
about: "HasLen: arrays with the same length",
|
1472 | 1492 |
checker: qt.HasLen,
|
1473 | 1493 |
got: [4]string{"these", "are", "the", "voyages"},
|
194 | 194 |
|
195 | 195 |
c.Assert(err, qt.IsNil)
|
196 | 196 |
|
|
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 |
|
197 | 206 |
IsTrue
|
198 | 207 |
|
199 | 208 |
IsTrue checks that the provided value is true.
|
34 | 34 |
return "s" + quoteString(s)
|
35 | 35 |
case string:
|
36 | 36 |
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)
|
37 | 40 |
}
|
38 | 41 |
if bytes, ok := byteSlice(v); ok && bytes != nil && utf8.Valid(bytes) {
|
39 | 42 |
// It's a top level slice of bytes that's also valid UTF-8.
|
107 | 107 |
about: "struct with byte slice",
|
108 | 108 |
value: struct{ X []byte }{[]byte("x")},
|
109 | 109 |
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 |
}
|
111 | 124 |
|
112 | 125 |
func TestFormat(t *testing.T) {
|
113 | 126 |
for _, test := range formatTests {
|