|
@@ -268,6 +268,8 @@ public class TestText {
|
|
|
0, text.getBytes().length);
|
|
|
assertEquals("String's length must be zero",
|
|
|
0, text.getLength());
|
|
|
+ assertEquals("String's text length must be zero",
|
|
|
+ 0, text.getTextLength());
|
|
|
|
|
|
// Test if clear works as intended
|
|
|
text = new Text("abcd\u20acbdcd\u20ac");
|
|
@@ -280,6 +282,8 @@ public class TestText {
|
|
|
text.getBytes().length >= len);
|
|
|
assertEquals("Length of the string must be reset to 0 after clear()",
|
|
|
0, text.getLength());
|
|
|
+ assertEquals("Text length of the string must be reset to 0 after clear()",
|
|
|
+ 0, text.getTextLength());
|
|
|
}
|
|
|
|
|
|
@Test
|
|
@@ -288,9 +292,12 @@ public class TestText {
|
|
|
Text b=new Text("a");
|
|
|
b.set(a);
|
|
|
assertEquals("abc", b.toString());
|
|
|
+ assertEquals(3, a.getTextLength());
|
|
|
+ assertEquals(3, b.getTextLength());
|
|
|
a.append("xdefgxxx".getBytes(), 1, 4);
|
|
|
assertEquals("modified aliased string", "abc", b.toString());
|
|
|
assertEquals("appended string incorrectly", "abcdefg", a.toString());
|
|
|
+ assertEquals("This should reflect in the lenght", 7, a.getTextLength());
|
|
|
// add an extra byte so that capacity = 10 and length = 8
|
|
|
a.append(new byte[]{'d'}, 0, 1);
|
|
|
assertEquals(10, a.getBytes().length);
|
|
@@ -392,16 +399,19 @@ public class TestText {
|
|
|
in.reset(inputBytes, inputBytes.length);
|
|
|
text.readWithKnownLength(in, 5);
|
|
|
assertEquals("hello", text.toString());
|
|
|
+ assertEquals(5, text.getTextLength());
|
|
|
|
|
|
// Read longer length, make sure it lengthens
|
|
|
in.reset(inputBytes, inputBytes.length);
|
|
|
text.readWithKnownLength(in, 7);
|
|
|
assertEquals("hello w", text.toString());
|
|
|
+ assertEquals(7, text.getTextLength());
|
|
|
|
|
|
// Read shorter length, make sure it shortens
|
|
|
in.reset(inputBytes, inputBytes.length);
|
|
|
text.readWithKnownLength(in, 2);
|
|
|
assertEquals("he", text.toString());
|
|
|
+ assertEquals(2, text.getTextLength());
|
|
|
}
|
|
|
|
|
|
/**
|