### Question:
GenericAddress implements Address { @Override public int compareTo(Address a) { int comp = addrSpace.compareTo(a.getAddressSpace()); if (comp == 0) { long otherOffset = a.getOffset(); if (!addrSpace.hasSignedOffset() && addrSpace.getMaxAddress().getOffset() < 0) { if ((offset < 0 && otherOffset >= 0) || (offset >= 0 && otherOffset < 0)) { return offset >= 0 ? -1 : 1; } } long diff = offset - otherOffset; if (diff > 0) { return 1; } if (diff < 0) { return -1; } } return comp; } GenericAddress(long offset, AddressSpace addrSpace);   GenericAddress(AddressSpace addrSpace, long offset); @Override Address getAddress(String addrString); @Override Address getNewAddress(long byteOffset); @Override Address getNewAddress(long addrOffset, boolean isAddressableWordOffset); @Override Address getNewTruncatedAddress(long addrOffset, boolean isAddressableWordOffset); @Override long getOffset(); @Override long getAddressableWordOffset(); @Override long getUnsignedOffset(); @Override AddressSpace getAddressSpace(); @Override int getSize(); @Override long subtract(Address addr); @Override Address subtractWrap(long displacement); @Override Address subtractWrapSpace(long displacement); @Override Address subtractNoWrap(long displacement); @Override Address subtract(long displacement); @Override Address addWrap(long displacement); @Override Address addWrapSpace(long displacement); @Override Address addNoWrap(long displacement); @Override Address addNoWrap(BigInteger displacement); @Override Address add(long displacement); @Override boolean isSuccessor(Address addr); @Override int compareTo(Address a); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); @Override String toString(String prefix); @Override String toString(boolean showAddressSpace); @Override String toString(boolean showAddressSpace, boolean pad); @Override String toString(boolean showAddressSpace, int minNumDigits); @Override boolean hasSameAddressSpace(Address addr); @Override Address next(); @Override Address previous(); @Override Address getPhysicalAddress(); @Override int getPointerSize(); @Override boolean isMemoryAddress(); @Override boolean isLoadedMemoryAddress(); @Override boolean isNonLoadedMemoryAddress(); @Override boolean isHashAddress(); @Override boolean isStackAddress(); @Override boolean isUniqueAddress(); @Override boolean isConstantAddress(); @Override boolean isVariableAddress(); @Override boolean isRegisterAddress(); @Override boolean isExternalAddress(); @Override BigInteger getOffsetAsBigInteger();  }### Answer:
@Test public void testCompareTo() { Address addr1 = new GenericAddress(space, 10); Address addr2 = addr1.getNewAddress(20); Address addr3 = addr1.getNewAddress(10); assertTrue(addr1.compareTo(addr2) < 0); assertTrue(addr2.compareTo(addr1) > 0); assertTrue(addr1.compareTo(addr3) == 0); Address addr4 = new GenericAddress(space, 10); assertTrue(addr1.compareTo(addr4) == 0); AddressSpace sp = new GenericAddressSpace("AnotherTest", 8, AddressSpace.TYPE_RAM, 1); Address addr5 = new GenericAddress(sp, 30); assertTrue(addr5.compareTo(addr1) > 0); }