(t *testing.T)
| 1035 | } |
| 1036 | |
| 1037 | func TestContainsNotContains(t *testing.T) { |
| 1038 | t.Parallel() |
| 1039 | |
| 1040 | type A struct { |
| 1041 | Name, Value string |
| 1042 | } |
| 1043 | list := []string{"Foo", "Bar"} |
| 1044 | |
| 1045 | complexList := []*A{ |
| 1046 | {"b", "c"}, |
| 1047 | {"d", "e"}, |
| 1048 | {"g", "h"}, |
| 1049 | {"j", "k"}, |
| 1050 | } |
| 1051 | simpleMap := map[interface{}]interface{}{"Foo": "Bar"} |
| 1052 | var zeroMap map[interface{}]interface{} |
| 1053 | |
| 1054 | cases := []struct { |
| 1055 | expected interface{} |
| 1056 | actual interface{} |
| 1057 | result bool |
| 1058 | }{ |
| 1059 | {"Hello World", "Hello", true}, |
| 1060 | {"Hello World", "Salut", false}, |
| 1061 | {list, "Bar", true}, |
| 1062 | {list, "Salut", false}, |
| 1063 | {complexList, &A{"g", "h"}, true}, |
| 1064 | {complexList, &A{"g", "e"}, false}, |
| 1065 | {simpleMap, "Foo", true}, |
| 1066 | {simpleMap, "Bar", false}, |
| 1067 | {zeroMap, "Bar", false}, |
| 1068 | } |
| 1069 | |
| 1070 | for _, c := range cases { |
| 1071 | t.Run(fmt.Sprintf("Contains(%#v, %#v)", c.expected, c.actual), func(t *testing.T) { |
| 1072 | mockT := new(testing.T) |
| 1073 | res := Contains(mockT, c.expected, c.actual) |
| 1074 | |
| 1075 | if res != c.result { |
| 1076 | if res { |
| 1077 | t.Errorf("Contains(%#v, %#v) should return true:\n\t%#v contains %#v", c.expected, c.actual, c.expected, c.actual) |
| 1078 | } else { |
| 1079 | t.Errorf("Contains(%#v, %#v) should return false:\n\t%#v does not contain %#v", c.expected, c.actual, c.expected, c.actual) |
| 1080 | } |
| 1081 | } |
| 1082 | }) |
| 1083 | } |
| 1084 | |
| 1085 | for _, c := range cases { |
| 1086 | t.Run(fmt.Sprintf("NotContains(%#v, %#v)", c.expected, c.actual), func(t *testing.T) { |
| 1087 | mockT := new(testing.T) |
| 1088 | res := NotContains(mockT, c.expected, c.actual) |
| 1089 | |
| 1090 | // NotContains should be inverse of Contains. If it's not, something is wrong |
| 1091 | if res == Contains(mockT, c.expected, c.actual) { |
| 1092 | if res { |
| 1093 | t.Errorf("NotContains(%#v, %#v) should return true:\n\t%#v does not contains %#v", c.expected, c.actual, c.expected, c.actual) |
| 1094 | } else { |
nothing calls this directly
no test coverage detected