assertSame
and assertNotSame
use the ==
operator:
public void testClone() {
Complex z1 = new Complex(1.0, 1.0);
Object z2 = z1.clone();
assertEquals(z1, z2);
assertNotSame(z1, z2);
}
Does this pass?
If so we don't need to
implement the clone()
method:
public Object clone() {
try {
return super.clone();
}
catch (CloneNotSupportedException e) {
throw new RuntimeException(e);
}
}