summaryrefslogtreecommitdiff
path: root/platform/util/testSrc/com/intellij/util
diff options
context:
space:
mode:
Diffstat (limited to 'platform/util/testSrc/com/intellij/util')
-rw-r--r--platform/util/testSrc/com/intellij/util/text/StringUtilTest.java19
-rw-r--r--platform/util/testSrc/com/intellij/util/xmlb/XmlSerializerTest.java16
2 files changed, 35 insertions, 0 deletions
diff --git a/platform/util/testSrc/com/intellij/util/text/StringUtilTest.java b/platform/util/testSrc/com/intellij/util/text/StringUtilTest.java
index 2f31dc4f4e61..383c07f2a87e 100644
--- a/platform/util/testSrc/com/intellij/util/text/StringUtilTest.java
+++ b/platform/util/testSrc/com/intellij/util/text/StringUtilTest.java
@@ -195,4 +195,23 @@ public class StringUtilTest extends TestCase {
assertEquals(Arrays.asList("\n", "\r\n", "\n", "\r\n", "\r", "\r", "aa\r", "bb\r\n", "cc\n", "\r", "dd\n", "\n", "\r\n", "\r"),
Arrays.asList(StringUtil.splitByLinesKeepSeparators("\n\r\n\n\r\n\r\raa\rbb\r\ncc\n\rdd\n\n\r\n\r")));
}
+
+ public void testShortened() {
+ String[] names = {"AVeryVeeryLongClassName.java", "com.test.SomeJAVAClassName.java", "strangelowercaseclassname.java", "PrefixPostfix.java", "SomeJAVAClassName.java"};
+ for (String name : names) {
+ for (int i = name.length() + 1; i > 15; i--) {
+ String shortened = StringUtil.getShortened(name, i);
+ assertTrue(shortened.length() <= i);
+ assertTrue(!shortened.contains("...."));
+ int pos = shortened.indexOf("...");
+ if (pos != -1) {
+ assertTrue(name.startsWith(shortened.substring(0, pos)));
+ assertTrue(name.endsWith(shortened.substring(pos + 3)));
+ }
+ else {
+ assertEquals(shortened, name);
+ }
+ }
+ }
+ }
}
diff --git a/platform/util/testSrc/com/intellij/util/xmlb/XmlSerializerTest.java b/platform/util/testSrc/com/intellij/util/xmlb/XmlSerializerTest.java
index 377abeba5b18..9a3fcb9d7066 100644
--- a/platform/util/testSrc/com/intellij/util/xmlb/XmlSerializerTest.java
+++ b/platform/util/testSrc/com/intellij/util/xmlb/XmlSerializerTest.java
@@ -495,6 +495,22 @@ public class XmlSerializerTest extends TestCase {
"</BeanWithFieldWithTagAnnotation>", bean);
}
+ public void testEscapeCharsInTagText() {
+ BeanWithFieldWithTagAnnotation bean = new BeanWithFieldWithTagAnnotation();
+ bean.STRING_V = "a\nb\"<";
+
+ doSerializerTest(
+ "<BeanWithFieldWithTagAnnotation>\n" +
+ " <name>a\nb&quot;&lt;</name>\n" +
+ "</BeanWithFieldWithTagAnnotation>", bean);
+ }
+
+ public void testEscapeCharsInAttributeValue() {
+ final BeanWithPropertiesBoundToAttribute bean = new BeanWithPropertiesBoundToAttribute();
+ bean.name = "a\nb\"<";
+ doSerializerTest("<BeanWithPropertiesBoundToAttribute count=\"3\" name=\"a&#10;b&quot;&lt;\" />", bean);
+ }
+
public void testShuffledDeserialize() {
BeanWithPublicFields bean = new BeanWithPublicFields();
bean.INT_V = 987;