Closed guojiex closed 1 year ago
map[int32]bool will have the same problem
@guojiex - You may be interested in my response to issue #30, which is very similar to this issue:
https://github.com/smartystreets/assertions/issues/30#issuecomment-370826288
To summarize:
Unlike the
ShouldEqual
assertion (which uses fairly loose comparison logic, allowingint(3)
to appear equal toint32(3)
), map keys should only be compared strictly (as if doing an==
comparison) because that is how map keys work...
How about printing some warning that the key type to compare is not the same as the key type defined in the map? This behavior is quite hidden and might cause confusion
the first assertion passed, while the second one will fail, error msg:
Expected the map[int64]bool to contain the key: [1] (but it didn't)!
My current temp solution will be:
So(map1[1], ShouldBeTrue)