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

Method NotInList

value.go:889–927  ·  view source on GitHub ↗

NotInList succeeds if the whole value is not equal to any of the values from given list of values (e.g. map, slice, string, etc). Before comparison, all values are converted to canonical form. If at least one value has wrong type, failure is reported. Example: value := NewValue(t, "foo") value.

(values ...interface{})

Source from the content-addressed store, hash-verified

887// value := NewValue(t, "foo")
888// value.NotInList("bar", 123)
889func (v *Value) NotInList(values ...interface{}) *Value {
890 opChain := v.chain.enter("NotInList()")
891 defer opChain.leave()
892
893 if opChain.failed() {
894 return v
895 }
896
897 if len(values) == 0 {
898 opChain.fail(AssertionFailure{
899 Type: AssertUsage,
900 Errors: []error{
901 errors.New("unexpected empty list argument"),
902 },
903 })
904 return v
905 }
906
907 for _, val := range values {
908 expected, ok := canonValue(opChain, val)
909 if !ok {
910 return v
911 }
912
913 if reflect.DeepEqual(expected, v.value) {
914 opChain.fail(AssertionFailure{
915 Type: AssertNotBelongs,
916 Actual: &AssertionValue{v.value},
917 Expected: &AssertionValue{AssertionList(values)},
918 Errors: []error{
919 errors.New("expected: value is not equal to any of the values"),
920 },
921 })
922 return v
923 }
924 }
925
926 return v
927}

Callers 15

TestDuration_FailedChainFunction · 0.45
TestDuration_InListFunction · 0.45
TestNumber_FailedChainFunction · 0.45
TestNumber_InListFunction · 0.45
TestString_FailedChainFunction · 0.45
TestString_InListFunction · 0.45
TestArray_FailedChainFunction · 0.45
TestArray_InListFunction · 0.45
TestDateTime_FailedChainFunction · 0.45
TestDateTime_InListFunction · 0.45
TestBoolean_FailedChainFunction · 0.45
TestBoolean_InListFunction · 0.45

Calls 6

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

Tested by 15

TestDuration_FailedChainFunction · 0.36
TestDuration_InListFunction · 0.36
TestNumber_FailedChainFunction · 0.36
TestNumber_InListFunction · 0.36
TestString_FailedChainFunction · 0.36
TestString_InListFunction · 0.36
TestArray_FailedChainFunction · 0.36
TestArray_InListFunction · 0.36
TestDateTime_FailedChainFunction · 0.36
TestDateTime_InListFunction · 0.36
TestBoolean_FailedChainFunction · 0.36
TestBoolean_InListFunction · 0.36