@Test public void testHarmonizeLineBreaks() { IWhitespaceInformationProvider whitespaceInformationProvider = get(IWhitespaceInformationProvider.class); URI uri = URI.createURI("example.txt"); String ls = whitespaceInformationProvider.getLineSeparatorInformation(uri).getLineSeparator(); assertFalse(isEmpty(ls)); LineSeparatorHarmonizer lineSeparatorHarmonizer = get(LineSeparatorHarmonizer.class); assertEquals(ls, lineSeparatorHarmonizer.postProcess(uri, "\n")); assertEquals(ls, lineSeparatorHarmonizer.postProcess(uri, "\r")); assertEquals(ls, lineSeparatorHarmonizer.postProcess(uri, "\n\r")); assertEquals(ls, lineSeparatorHarmonizer.postProcess(uri, "\r\n")); assertEquals("0" + ls + "1" + ls + "2", lineSeparatorHarmonizer.postProcess(uri, "0\n1\r2")); assertEquals("0" + ls + "1" + ls + "2", lineSeparatorHarmonizer.postProcess(uri, "0\n\r1\r\n2")); assertEquals("0" + ls + ls + "1", lineSeparatorHarmonizer.postProcess(uri, "0\n\r\n\r1")); assertEquals("0" + ls + ls + "1", lineSeparatorHarmonizer.postProcess(uri, "0\r\n\r\n1")); assertEquals("0" + ls + ls + ls + "1", lineSeparatorHarmonizer.postProcess(uri, "0\n\r\n\r\n1")); assertEquals("0" + ls + ls + ls + "1", lineSeparatorHarmonizer.postProcess(uri, "0\r\n\r\n\r1")); }
protected IWhitespaceInformationProvider getWhitespaceInformationProvider() { return whitespaceInformationProvider; }
/** * @since 2.3 */ public Class<? extends IWhitespaceInformationProvider> bindIWhitespaceInformationProvider() { return PreferenceStoreWhitespaceInformationProvider.class; }