### Question:
CreateMultipleFunctionsCmd extends BackgroundCommand { @Override public boolean applyTo(DomainObject obj, TaskMonitor monitor) { program = (Program) obj; Listing listing = program.getListing(); AddressSet addressSet = new AddressSet(selection); Address address = addressSet.getMinAddress(); int functionsCreated = 0; long numInitialAddresses = addressSet.getNumAddresses(); monitor.initialize(numInitialAddresses); monitor.setMessage("Creating functions from selection."); while (address != null && !monitor.isCancelled()) { Function function = listing.getFunctionContaining(address); if (function == null) { Function createdFunction = createFunction(address, program, monitor); if (createdFunction != null) { functionsCreated++; } } if (function != null) { AddressSetView body = function.getBody(); addressSet.delete(body); } addressSet.deleteRange(address, address); address = addressSet.getMinAddress(); long numRemainingAddresses = addressSet.getNumAddresses(); monitor.setProgress(numInitialAddresses - numRemainingAddresses); } if (monitor.isCancelled()) { Msg.info(this, "User canceled " + getName() + "."); return false; } Msg.info(this, functionsCreated + " functions created by " + getName() + "."); return true; } CreateMultipleFunctionsCmd(AddressSetView selection, SourceType source); @Override boolean applyTo(DomainObject obj, TaskMonitor monitor); final Function createFunction(Address entryPoint, Program currentProgram,
			TaskMonitor monitor);  }### Answer:
@Test public void testCreateMultipleFunctionsWithSingleRangeSelection() { AddressSet selection = new AddressSet(addr(0x0), addr(0x20)); int transactionID = program.startTransaction("Perform the TEST"); CreateMultipleFunctionsCmd createCmd = new CreateMultipleFunctionsCmd(selection, SourceType.USER_DEFINED); createCmd.applyTo(program); program.endTransaction(transactionID, true); assertNotNull(func(addr(0x0))); assertNotNull(func(addr(0x5))); assertNotNull(func(addr(0xe))); assertNotNull(func(addr(0x18))); assertNotNull(func(addr(0x1d))); }
@Test public void testCreateMultipleFunctionsWithMultipleEntryPointSelection() { AddressSet selection = new AddressSet(); selection.add(addr(0x0)); selection.add(addr(0x5)); selection.add(addr(0xe)); selection.add(addr(0x18)); selection.add(addr(0x1d)); int transactionID = program.startTransaction("Perform the TEST"); CreateMultipleFunctionsCmd createCmd = new CreateMultipleFunctionsCmd(selection, SourceType.USER_DEFINED); createCmd.applyTo(program); program.endTransaction(transactionID, true); assertNotNull(func(addr(0x0))); assertNotNull(func(addr(0x5))); assertNotNull(func(addr(0xe))); assertNotNull(func(addr(0x18))); assertNotNull(func(addr(0x1d))); }
@Test public void testCreateMultipleFunctionsWithMultipleOffsetRangeSelection() { AddressSet selection = new AddressSet(); selection.addRange(addr(0x2), addr(0x7)); selection.addRange(addr(0xf), addr(0x1a)); int transactionID = program.startTransaction("Perform the TEST"); CreateMultipleFunctionsCmd createCmd = new CreateMultipleFunctionsCmd(selection, SourceType.USER_DEFINED); createCmd.applyTo(program); program.endTransaction(transactionID, true); assertNotNull(func(addr(0x2))); assertNotNull(func(addr(0x5))); assertNotNull(func(addr(0xf))); assertNotNull(func(addr(0x18))); assertNull(func(addr(0x0))); assertNull(func(addr(0xe))); assertNull(func(addr(0x1d))); }