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)
| 468 | // str := NewString(t, "Hello") |
| 469 | // str.NotInListFold("Bye", "Goodbye") |
| 470 | func (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 | // |