MCPcopy Create free account
hub / github.com/gavv/httpexpect / Boolean

Method Boolean

value.go:362–384  ·  view source on GitHub ↗

Boolean returns a new Boolean attached to underlying value. If underlying value is not a bool, failure is reported and empty (but non-nil) value is returned. Example: value := NewValue(t, true) value.Boolean().IsTrue()

()

Source from the content-addressed store, hash-verified

360// value := NewValue(t, true)
361// value.Boolean().IsTrue()
362func (v *Value) Boolean() *Boolean {
363 opChain := v.chain.enter("Boolean()")
364 defer opChain.leave()
365
366 if opChain.failed() {
367 return newBoolean(opChain, false)
368 }
369
370 data, ok := v.value.(bool)
371
372 if !ok {
373 opChain.fail(AssertionFailure{
374 Type: AssertValid,
375 Actual: &AssertionValue{v.value},
376 Errors: []error{
377 errors.New("expected: value is boolean"),
378 },
379 })
380 return newBoolean(opChain, false)
381 }
382
383 return newBoolean(opChain, data)
384}
385
386// IsNull succeeds if value is nil.
387//

Callers 4

TestValue_GetBooleanFunction · 0.95
TestExpect_TraverseFunction · 0.45
TestValue_FailedChainFunction · 0.45
TestValue_GettersFunction · 0.45

Calls 5

newBooleanFunction · 0.85
enterMethod · 0.80
leaveMethod · 0.80
failedMethod · 0.80
failMethod · 0.80

Tested by 4

TestValue_GetBooleanFunction · 0.76
TestExpect_TraverseFunction · 0.36
TestValue_FailedChainFunction · 0.36
TestValue_GettersFunction · 0.36