Mercurial > stress-tester
changeset 1007:bacaa71e4d16
NcDataHelper - bugfix
author | Devel 1 |
---|---|
date | Wed, 18 Mar 2020 13:29:01 +0100 |
parents | dadf915aa1f6 |
children | 469c65b34298 |
files | stress-tester/src/main/java/com/passus/st/reader/nc/NcDataHelper.java stress-tester/src/test/java/com/passus/st/reader/nc/NcDataHelperTest.java |
diffstat | 2 files changed, 7 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/reader/nc/NcDataHelper.java Wed Mar 18 12:28:07 2020 +0100 +++ b/stress-tester/src/main/java/com/passus/st/reader/nc/NcDataHelper.java Wed Mar 18 13:29:01 2020 +0100 @@ -326,7 +326,7 @@ if (length == 0) { value = ""; } else { - value = buffer.toString(startIndex, length, CHARSET); + value = buffer.toString0(startIndex, length, CHARSET); } buffer.skipBytes(length + 1); return value;
--- a/stress-tester/src/test/java/com/passus/st/reader/nc/NcDataHelperTest.java Wed Mar 18 12:28:07 2020 +0100 +++ b/stress-tester/src/test/java/com/passus/st/reader/nc/NcDataHelperTest.java Wed Mar 18 13:29:01 2020 +0100 @@ -185,5 +185,11 @@ res = helper.readStringNullTerminated(buffer); assertEquals("", res); assertEquals(0, buffer.readableBytes()); + + buffer = new HeapByteBuff(new byte[]{0x31, 0x32, 0x33, 0x34, 0x35, 0x36, AsciiUtils.NUL}); + buffer.startIndex(3); + res = helper.readStringNullTerminated(buffer); + assertEquals("456", res); + assertEquals(0, buffer.readableBytes()); } }