| 939 | } |
| 940 | |
| 941 | func TestNotEqual(t *testing.T) { |
| 942 | t.Parallel() |
| 943 | mockT := new(testing.T) |
| 944 | |
| 945 | cases := []struct { |
| 946 | expected interface{} |
| 947 | actual interface{} |
| 948 | result bool |
| 949 | }{ |
| 950 | // cases that are expected not to match |
| 951 | {"Hello World", "Hello World!", true}, |
| 952 | {123, 1234, true}, |
| 953 | {123.5, 123.55, true}, |
| 954 | {[]byte("Hello World"), []byte("Hello World!"), true}, |
| 955 | {nil, new(AssertionTesterConformingObject), true}, |
| 956 | |
| 957 | // cases that are expected to match |
| 958 | {nil, nil, false}, |
| 959 | {"Hello World", "Hello World", false}, |
| 960 | {123, 123, false}, |
| 961 | {123.5, 123.5, false}, |
| 962 | {[]byte("Hello World"), []byte("Hello World"), false}, |
| 963 | {new(AssertionTesterConformingObject), new(AssertionTesterConformingObject), false}, |
| 964 | {&struct{}{}, &struct{}{}, false}, |
| 965 | {func() int { return 23 }, func() int { return 24 }, false}, |
| 966 | // A case that might be confusing, especially with numeric literals |
| 967 | {int(10), uint(10), true}, |
| 968 | } |
| 969 | |
| 970 | for _, c := range cases { |
| 971 | t.Run(fmt.Sprintf("NotEqual(%#v, %#v)", c.expected, c.actual), func(t *testing.T) { |
| 972 | res := NotEqual(mockT, c.expected, c.actual) |
| 973 | |
| 974 | if res != c.result { |
| 975 | t.Errorf("NotEqual(%#v, %#v) should return %#v", c.expected, c.actual, c.result) |
| 976 | } |
| 977 | }) |
| 978 | } |
| 979 | } |
| 980 | |
| 981 | func TestEqualValuesAndNotEqualValues(t *testing.T) { |
| 982 | t.Parallel() |