@Test
	public void testStringsContainingRefs() throws Exception {

		Program testProgram = buildProgram("libopencoreplayer.so", false);

		Listing listing = testProgram.getListing();
		AddressSpace space = testProgram.getLanguage().getAddressFactory().getDefaultAddressSpace();

		// Offsets where there shouldn't be strings because existing refs were "in the way"
		int[] nonExpectedOffsets = new int[] { 0xa7195fd4, 0xa7196ee8 };
		Data dataHere;

		// Verify these aren't here before running Strings Analyzer
		for (int nonExpectedOffset : nonExpectedOffsets) {
			dataHere = listing.getDefinedDataAt(addr(space, nonExpectedOffset));
			assertNull(dataHere);
		}

		// Create references
		ReferenceManager refMgr = testProgram.getReferenceManager();
		refMgr.addMemoryReference(addr(space, 0xa7197898), addr(space, 0xa7195fda), RefType.DATA,
			SourceType.USER_DEFINED, 1);

		refMgr.addMemoryReference(addr(space, 0xa7196f62), addr(space, 0xa7196efc), RefType.DATA,
			SourceType.USER_DEFINED, 1);

		AutoAnalysisManager manager = AutoAnalysisManager.getAnalysisManager(testProgram);

		// Run strings analyzer
		StringsAnalyzer analyzer = new StringsAnalyzer();
		analyzer.setCreateStringOverExistingReference(false);// Option is unchecked
		analyzer.setStringEndAlignment(1);
		analyzer.added(testProgram, null, monitor, manager.getMessageLog());

		for (int nonExpectedOffset : nonExpectedOffsets) {
			dataHere = listing.getDefinedDataAt(addr(space, nonExpectedOffset));
			assertNull(dataHere);
		}

		// String that would have been created if parameter is checked
		String[] largerStrs = new String[] { "PVFMVideoMIO", "set to invalid mode (%d)" };
		String[] nullBits = new String[] { "00", "00" };

		// Now run again with parameter enabled and verify strings are there
		analyzer.setCreateStringOverExistingReference(true);// Option is checked
		analyzer.added(testProgram, null, monitor, manager.getMessageLog());

		String stringHere;
		for (int i = 0; i < nonExpectedOffsets.length; i++) {
			dataHere = listing.getDefinedDataAt(addr(space, nonExpectedOffsets[i]));
			assertNotNull(dataHere);
			stringHere = dataHere.getDefaultValueRepresentation();
			assertEquals("\"" + largerStrs[i] + "\"", stringHere);
		}
	}
Verify that unchecking then checking the "Create strings containing references"
 option works as expected.
Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/string/StringsAnalyzerTest.java