Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSarika Sinha2017-03-04 13:27:55 +0000
committerSarika Sinha2017-03-04 13:27:55 +0000
commitf8b78f2946e2965bc5bcd90c199e3982e844a831 (patch)
tree71df3906aa9f25a810aa7f66191c079ec3166c85 /org.eclipse.debug.tests
parentfd0dda7c8cf10980c2b9e0f2e83d640d8455f7b9 (diff)
downloadeclipse.platform.debug-f8b78f2946e2965bc5bcd90c199e3982e844a831.tar.gz
eclipse.platform.debug-f8b78f2946e2965bc5bcd90c199e3982e844a831.tar.xz
eclipse.platform.debug-f8b78f2946e2965bc5bcd90c199e3982e844a831.zip
at buffer boundaries correctly Change-Id: Iee66ccfd74f93760b1c0e26c7114d4b48cee6324
Diffstat (limited to 'org.eclipse.debug.tests')
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ConsoleTests.java25
1 files changed, 25 insertions, 0 deletions
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ConsoleTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ConsoleTests.java
index 3939c4d3a..b683fe22e 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ConsoleTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ConsoleTests.java
@@ -55,6 +55,31 @@ public class ConsoleTests extends TestCase {
TestHelper.waitForJobs();
TestCase.assertEquals("whole test string should be written", testString, document.get()); //$NON-NLS-1$
}
+ TestHelper.waitForJobs();
+ // after closing the stream, the document content should still be the
+ // same
+ TestCase.assertEquals("closing the stream should not alter the document", testString, document.get()); //$NON-NLS-1$
+ }
+
+ public void testConsoleOutputStreamLastR() throws IOException, InterruptedException {
+ String testString = "a\r"; //$NON-NLS-1$
+ byte[] testStringBuffer = testString.getBytes(StandardCharsets.UTF_8);
+ TestCase.assertEquals("Test string \"" + testString + "\" should consist of 2 UTF-8 bytes", 2, testStringBuffer.length); //$NON-NLS-1$ //$NON-NLS-2$
+ MessageConsole console = new MessageConsole("Test Console", //$NON-NLS-1$
+ IConsoleConstants.MESSAGE_CONSOLE_TYPE, null, StandardCharsets.UTF_8.name(), true);
+ IDocument document = console.getDocument();
+ TestHelper.waitForJobs();
+ TestCase.assertEquals("Document should be empty", "", document.get()); //$NON-NLS-1$ //$NON-NLS-2$
+ try (IOConsoleOutputStream outStream = console.newOutputStream()) {
+ outStream.write(testStringBuffer);
+ // everything but pending \r should be written
+ TestHelper.waitForJobs();
+ TestCase.assertEquals("First char should be written", testString.substring(0, 1), document.get()); //$NON-NLS-1$
+ }
+ TestHelper.waitForJobs();
+ // after closing the stream, the document content should still be the
+ // same
+ TestCase.assertEquals("closing the stream should write the pending \\r", testString, document.get()); //$NON-NLS-1$
}
}

Back to the top