Add ImString support for "null" values

Set with "null" as a value will work in the same way String#valueOf does.
This commit is contained in:
SpaiR committed 2020-06-25 15:26:49 +03:00
1 parent 74cfec5a2a
commit 5c1f8f5c33
2 files changed
+4 -1

No files matched your search

@@ -90,7 +90,7 @@ public final class ImString implements Cloneable {
} }
public void set(final String value, final boolean resize, final int resizeValue) { public void set(final String value, final boolean resize, final int resizeValue) {
final byte[] valueBuff = value.getBytes(); final byte[] valueBuff = (value == null ? "null" : value).getBytes();
final int currentLen = data == null ? 0 : data.length; final int currentLen = data == null ? 0 : data.length;
byte[] newBuff = null; byte[] newBuff = null;
@@ -52,5 +52,8 @@ class ImStringTest {
assertEquals("0123456789", str.get()); assertEquals("0123456789", str.get());
assertEquals(10, str.getLength()); assertEquals(10, str.getLength());
assertEquals(10 + str.inputData.resizeFactor + 1, str.getBufferSize()); assertEquals(10 + str.inputData.resizeFactor + 1, str.getBufferSize());
str.set(null);
assertEquals("null", str.get());
} }
} }