MCPcopy Index your code
hub / github.com/gavv/httpexpect / NotInListFold

Method NotInListFold

string.go:470–509  ·  view source on GitHub ↗

NotInListFold succeeds if the string is not equal to any of the values from given list of strings after applying Unicode case-folding (so it's a case-insensitive match). Example: str := NewString(t, "Hello") str.NotInListFold("Bye", "Goodbye")

(values ...string)

Source from the content-addressed store, hash-verified

468// str := NewString(t, "Hello")
469// str.NotInListFold("Bye", "Goodbye")
470func (s *String) NotInListFold(values ...string) *String {
471 opChain := s.chain.enter("NotInListFold()")
472 defer opChain.leave()
473
474 if opChain.failed() {
475 return s
476 }
477
478 if len(values) == 0 {
479 opChain.fail(AssertionFailure{
480 Type: AssertUsage,
481 Errors: []error{
482 errors.New("unexpected empty list argument"),
483 },
484 })
485 return s
486 }
487
488 for _, v := range values {
489 if strings.EqualFold(s.value, v) {
490 valueList := make([]interface{}, 0, len(values))
491 for _, v := range values {
492 valueList = append(valueList, v)
493 }
494
495 opChain.fail(AssertionFailure{
496 Type: AssertNotBelongs,
497 Actual: &AssertionValue{s.value},
498 Expected: &AssertionValue{AssertionList(valueList)},
499 Errors: []error{
500 errors.New("expected: string is not equal to any of the values (if folded)"),
501 },
502 })
503
504 return s
505 }
506 }
507
508 return s
509}
510
511// Contains succeeds if string contains given Go string as a substring.
512//

Callers 2

TestString_FailedChainFunction · 0.80
TestString_InListFunction · 0.80

Calls 6

AssertionListTypeAlias · 0.85
enterMethod · 0.80
leaveMethod · 0.80
failedMethod · 0.80
failMethod · 0.80
EqualFoldMethod · 0.80

Tested by 2

TestString_FailedChainFunction · 0.64
TestString_InListFunction · 0.64