IDEA-74544 Copy-Paste a string literal with '\n' character inserts actual line-feed instead of '\n'

StringLiteralCopyPasteProcessor handles string literals at the pasted text now
This commit is contained in:
Denis.Zhdanov
2011-10-04 14:28:34 +04:00
parent 9e9228da43
commit 4642c32042
2 changed files with 62 additions and 0 deletions
@@ -0,0 +1,25 @@
package com.intellij.codeInsight.editorActions;
import org.jetbrains.annotations.NotNull;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
* @author Denis Zhdanov
* @since 10/4/11 1:28 PM
*/
public class StringLiteralCopyPasteProcessorTest {
@Test
public void escapePastedStringLiteral() {
doEscapePastedStringLiteralTest("identity", "identity");
doEscapePastedStringLiteralTest("\"complete \n literal\"", "\"complete \\n literal\"");
doEscapePastedStringLiteralTest("\"incomplete \n literal", "\"incomplete \n literal");
doEscapePastedStringLiteralTest("partial \"string \n literal\"", "partial \"string \\n literal\"");
}
private static void doEscapePastedStringLiteralTest(@NotNull String initial, @NotNull String expected) {
assertEquals(expected, StringLiteralCopyPasteProcessor.escapePastedLiteral(initial));
}
}