@Test
	public void testGetDefinedDataIterator() throws Exception {
		startTransaction();
		mem.removeBlock(mem.getBlock(addr(1000)), monitor);
		mem.createInitializedBlock("test", addr(0), 1000, (byte) 0, TaskMonitor.DUMMY, false);

		for (int i = 0; i < 10; i++) {
			listing.createData(addr(i), new ByteDataType(), 1);
		}

		Structure struct = new StructureDataType("struct_1", 100);
		Structure struct2 = new StructureDataType("struct_2", 0);
		Structure struct3 = new StructureDataType("struct_3", 0);
		DataTypeManager dtm = new StandAloneDataTypeManager("dummyDTM");
		int id = dtm.startTransaction("");
		struct = (Structure) dtm.resolve(struct, null);
		struct2 = (Structure) dtm.resolve(struct2, null);
		struct3 = (Structure) dtm.resolve(struct3, null);

		struct2.add(new ByteDataType());
		struct2.add(new StringDataType(), 20);
		struct2.add(new QWordDataType());
		struct3.add(struct2);

		struct.replace(0, struct2, struct2.getLength());
		struct.replace(1, new StringDataType(), 10);

		listing.createData(addr(12), struct, 0);
		listing.createData(addr(300), struct2, 0);
		listing.createData(addr(250), struct3, 0);

		listing.createData(addr(500), new QWordDataType(), 0);
		listing.createData(addr(550), new FloatDataType(), 0);
		endTransaction();

		DataIterator iter = listing.getDefinedData(true);
		for (int i = 0; i < 10; i++) {
			Data d = iter.next();
			assertNotNull(d);
			assertEquals(addr(i), d.getMinAddress());
		}

		Data d = iter.next();
		assertNotNull(d);
		assertEquals(addr(12), d.getMinAddress());
		assertEquals("struct_1", d.getDataType().getName());

		d = iter.next();
		assertNotNull(d);
		assertEquals(addr(250), d.getMinAddress());
		assertEquals("struct_3", d.getDataType().getName());

		d = iter.next();
		assertNotNull(d);
		assertEquals(addr(300), d.getMinAddress());
		assertEquals("struct_2", d.getDataType().getName());

		d = iter.next();
		assertNotNull(d);
		assertEquals(addr(500), d.getMinAddress());
		assertTrue(d.getDataType() instanceof QWordDataType);

		d = iter.next();
		assertNotNull(d);
		assertEquals(addr(550), d.getMinAddress());
		assertTrue(d.getDataType() instanceof FloatDataType);

		assertTrue(!iter.hasNext());
		dtm.endTransaction(id, true);
		dtm.close();
	}
** Diagnostic Aid ** Open program in tool
@throws Exception
Ghidra/Features/Base/src/test.slow/java/ghidra/program/database/code/CodeUnitIteratorTest.java