### Question:
InstructionSet implements Iterable<InstructionBlock> { @Override public Iterator<InstructionBlock> iterator() { return new BlockIterator(); } InstructionSet(AddressFactory addrFactory); void addBlock(InstructionBlock block); InstructionBlock getInstructionBlockContaining(Address address); InstructionBlock findFirstIntersectingBlock(Address min, Address max); Instruction getInstructionAt(Address address); Address getMinAddress(); AddressSetView getAddressSet(); @Override String toString(); int getInstructionCount(); boolean containsBlockAt(Address blockAddr); boolean intersects(Address minAddress, Address maxAddress); @Override Iterator<InstructionBlock> iterator(); Iterator<InstructionBlock> emptyBlockIterator(); List<InstructionError> getConflicts();  }### Answer:
@Test public void testBasicIterator() { Iterator<InstructionBlock> it = instructionSet.iterator(); assertTrue(it.hasNext()); InstructionBlock next = it.next(); Assert.assertEquals(addr(0), next.getStartAddress()); assertTrue(it.hasNext()); next = it.next(); Assert.assertEquals(addr(0x20), next.getStartAddress()); assertTrue(it.hasNext()); next = it.next(); Assert.assertEquals(addr(0x30), next.getStartAddress()); assertTrue(it.hasNext()); next = it.next(); Assert.assertEquals(addr(0x40), next.getStartAddress()); assertTrue(it.hasNext()); next = it.next(); Assert.assertEquals(addr(0x10), next.getStartAddress()); assertTrue(it.hasNext()); next = it.next(); Assert.assertEquals(addr(0x50), next.getStartAddress()); assertTrue(it.hasNext()); next = it.next(); Assert.assertEquals(addr(0x70), next.getStartAddress()); assertTrue(it.hasNext()); next = it.next(); Assert.assertEquals(addr(0x60), next.getStartAddress()); assertFalse(it.hasNext()); assertNull(it.next()); }
@Test public void testBlock30HasConflict() { Iterator<InstructionBlock> it = instructionSet.iterator(); assertTrue(it.hasNext()); InstructionBlock next = it.next(); Assert.assertEquals(addr(00), next.getStartAddress()); assertTrue(it.hasNext()); next = it.next(); Assert.assertEquals(addr(0x20), next.getStartAddress()); assertTrue(it.hasNext()); next = it.next(); Assert.assertEquals(addr(0x30), next.getStartAddress()); next.setInstructionError(InstructionErrorType.INSTRUCTION_CONFLICT, addr(0x33), addr(0x34), null, "Test conflict"); assertTrue(it.hasNext()); next = it.next(); Assert.assertEquals(addr(0x40), next.getStartAddress()); assertTrue(it.hasNext()); next = it.next(); Assert.assertEquals(addr(0x70), next.getStartAddress()); next.setInstructionError(InstructionErrorType.INSTRUCTION_CONFLICT, addr(0x73), addr(0x74), null, "Test conflict"); assertFalse(it.hasNext()); assertNull(it.next()); }