diff options
author | Sarika Sinha | 2017-03-04 13:27:55 +0000 |
---|---|---|
committer | Sarika Sinha | 2017-03-04 13:27:55 +0000 |
commit | f8b78f2946e2965bc5bcd90c199e3982e844a831 (patch) | |
tree | 71df3906aa9f25a810aa7f66191c079ec3166c85 /org.eclipse.debug.tests | |
parent | fd0dda7c8cf10980c2b9e0f2e83d640d8455f7b9 (diff) | |
download | eclipse.platform.debug-f8b78f2946e2965bc5bcd90c199e3982e844a831.tar.gz eclipse.platform.debug-f8b78f2946e2965bc5bcd90c199e3982e844a831.tar.xz eclipse.platform.debug-f8b78f2946e2965bc5bcd90c199e3982e844a831.zip |
Bug 507664 - IOConsoleOutputStream does not handle multi-byte charactersY20170309-1000S4_7_0_M6I20170308-2000I20170308-0800I20170307-2000I20170307-0800I20170307-0610I20170307-0450I20170307-0420I20170307-0410I20170307-0150I20170306-2000I20170306-0800I20170305-2000I20170304-2000
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.java | 25 |
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$ } } |