JUnit theory for hashCode/equals contract

前端 未结 5 1278
情深已故
情深已故 2020-12-07 19:05

The following class serve as generic tester for equals/hashCode contract. It is a part of a home grown testing framework.

  • What do you think about?
  • Ho
5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-07 19:42

    Maybe I'm missing something, but the equalsIsSymmetric test is in fact only correctly tested if you have to DataPoints which have the same values (e.g. String a = "a"; String a2 = "a";) Otherwise this test is only done when the 2 parameters are one instance (i.e. equalsIsSymmetric(a, a);). In fact you test again if equals obey the 'reflective' requirement instead of the symmetric requirement.

提交回复
热议问题