### Question:
GenericAddress implements Address { @Override public long getOffset() { return offset; } 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 testCreateMemAddress() { GenericAddress addr = new GenericAddress(space, 5); Assert.assertEquals(5, addr.getOffset()); try { addr = new GenericAddress(space, 257); Assert.fail("Should not have created address!"); } catch (AddressOutOfBoundsException e) { } try { addr = new GenericAddress(space, -300); Assert.fail("Should not have created address!"); } catch (AddressOutOfBoundsException e) { } }
@Test public void testCreateRegAddress() { GenericAddress addr = new GenericAddress(regSpace, 5); Assert.assertEquals(5, addr.getOffset()); addr = new GenericAddress(regSpace, -5); Assert.assertEquals(-5L & 0x0ffL, addr.getOffset()); try { addr = new GenericAddress(regSpace, 1024); Assert.fail("Should not have created address!"); } catch (AddressOutOfBoundsException e) { } try { addr = new GenericAddress(regSpace, -257); Assert.fail("Should not have created address!"); } catch (AddressOutOfBoundsException e) { } }
@Test public void testCreateStackAddress() { GenericAddress addr = new GenericAddress(stackSpace, 5); Assert.assertEquals(5, addr.getOffset()); addr = new GenericAddress(stackSpace, -5); Assert.assertEquals(-5, addr.getOffset()); try { addr = new GenericAddress(stackSpace, 256); Assert.fail("Should not have created address!"); } catch (AddressOutOfBoundsException e) { } try { addr = new GenericAddress(stackSpace, -129); Assert.fail("Should not have created address!"); } catch (AddressOutOfBoundsException e) { } }