@Test
    public void testSubtract() {

		Assert.assertEquals(10, space.subtract(addr(1, 32), addr(1, 22)));
		Assert.assertEquals(-16, space.subtract(addr(5, 0), addr(5, 16)));
		Assert.assertEquals(0, space.subtract(addr(3, 12), addr(3, 12)));
		Assert.assertEquals(0, space.subtract(addr(2, 0), addr(0, 32)));
		Assert.assertEquals(16, space.subtract(addr(1, 0), addr(0, 0)));
		Assert.assertEquals(-16, space.subtract(addr(0, 0), addr(1, 0)));

		SegmentedAddressSpace sp2 = new SegmentedAddressSpace("SpaceTwo", 2);
		SegmentedAddress addr2 = new SegmentedAddress(sp2, 0, 0);

		try {
			space.subtract(addr(0, 0), addr2);
			Assert.fail("Subtract should have failed!");
		}
		catch (IllegalArgumentException e) {
		}

		Assert.assertEquals(addr(4, 2), space.subtract(addr(4, 5), 3));
		Assert.assertEquals(addr(0, 0x2f), space.subtract(addr(3, 0), 1));
		Assert.assertEquals(addr(13, 9), space.subtract(addr(13, 5), -4));
		try {
			Assert.assertEquals(addr(0, 0), space.subtract(addr(0, 0), 0x100000));
			Assert.fail();
		}
		catch (AddressOutOfBoundsException e) {
		}

		try {
			Assert.assertEquals(addr(0, 2), space.subtractNoWrap(addr(0, 5), 3));

			Assert.assertEquals(addr(3, 9), space.subtractNoWrap(addr(3, 5), -4));
		}
		catch (AddressOverflowException e) {
			Assert.fail(e.getMessage());
		}

		try {
			space.subtractNoWrap(addr(0, 5), 0x10000);
			Assert.fail("Should not have gotten a value!");
		}
		catch (AddressOverflowException e) {
		}

	}
To change this generated comment edit the template variable "typecomment":
Window>Preferences>Java>Templates.
Ghidra/Framework/SoftwareModeling/src/test/java/ghidra/program/model/address/SegmentedAddressSpaceTest.java