assertEquals(sf1.hashCode(), sf2.hashCode());
// changing type breaks equals:
+ String restores = sf2.getType();
sf2.setType("Type");
assertFalse(sf1.equals(sf2));
+ sf2.setType(restores);
// changing description breaks equals:
- sf2.setType("type");
+ restores = sf2.getDescription();
sf2.setDescription("Desc");
assertFalse(sf1.equals(sf2));
+ sf2.setDescription(restores);
+
+ // changing score breaks equals:
+ float restoref = sf2.getScore();
+ sf2.setScore(12.4f);
+ assertFalse(sf1.equals(sf2));
+ sf2.setScore(restoref);
+
+ // NaN doesn't match a number
+ restoref = sf2.getScore();
+ sf2.setScore(Float.NaN);
+ assertFalse(sf1.equals(sf2));
+
+ // NaN matches NaN
+ sf1.setScore(Float.NaN);
+ assertTrue(sf1.equals(sf2));
+ sf1.setScore(restoref);
+ sf2.setScore(restoref);
// changing start position breaks equals:
- sf2.setDescription("desc");
+ int restorei = sf2.getBegin();
sf2.setBegin(21);
assertFalse(sf1.equals(sf2));
+ sf2.setBegin(restorei);
// changing end position breaks equals:
- sf2.setBegin(22);
+ restorei = sf2.getEnd();
sf2.setEnd(32);
assertFalse(sf1.equals(sf2));
+ sf2.setEnd(restorei);
// changing feature group breaks equals:
- sf2.setEnd(33);
+ restores = sf2.getFeatureGroup();
sf2.setFeatureGroup("Group");
assertFalse(sf1.equals(sf2));
+ sf2.setFeatureGroup(restores);
// changing ID breaks equals:
- sf2.setFeatureGroup("group");
+ restores = (String) sf2.getValue("ID");
sf2.setValue("ID", "id2");
assertFalse(sf1.equals(sf2));
+ sf2.setValue("ID", restores);
// changing Name breaks equals:
- sf2.setValue("ID", "id");
+ restores = (String) sf2.getValue("Name");
sf2.setValue("Name", "Name");
assertFalse(sf1.equals(sf2));
+ sf2.setValue("Name", restores);
// changing Parent breaks equals:
- sf2.setValue("Name", "name");
+ restores = (String) sf1.getValue("Parent");
sf1.setValue("Parent", "Parent");
assertFalse(sf1.equals(sf2));
+ sf1.setValue("Parent", restores);
// changing strand breaks equals:
- sf1.setValue("Parent", "parent");
+ restorei = sf2.getStrand();
sf2.setStrand("-");
assertFalse(sf1.equals(sf2));
+ sf2.setStrand(restorei == 1 ? "+" : "-");
// changing phase breaks equals:
- sf2.setStrand("+");
+ restores = sf1.getPhase();
sf1.setPhase("2");
assertFalse(sf1.equals(sf2));
+ sf1.setPhase(restores);
// restore equality as sanity check:
- sf1.setPhase("1");
assertTrue(sf1.equals(sf2));
assertTrue(sf2.equals(sf1));
assertEquals(sf1.hashCode(), sf2.hashCode());