diff options
author | Dominik Stadler <centic@apache.org> | 2018-02-08 19:34:16 +0000 |
---|---|---|
committer | Dominik Stadler <centic@apache.org> | 2018-02-08 19:34:16 +0000 |
commit | 21e5140462255224d9261a7575e89b35255ec0ac (patch) | |
tree | 1be4e7bc40c56b3219d69c92fbd8499568d079c7 /src/testcases/org/apache/poi/util/TestLittleEndianStreams.java | |
parent | a911347aae82b44d6bf9c894a9846c28f7fb338f (diff) | |
download | poi-21e5140462255224d9261a7575e89b35255ec0ac.tar.gz poi-21e5140462255224d9261a7575e89b35255ec0ac.zip |
Various smaller adjustments: Remove filename in test, remove unused parameters, fix a few simple typos in JavaDoc and add more JavaDoc and some more tests
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1823595 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/util/TestLittleEndianStreams.java')
-rw-r--r-- | src/testcases/org/apache/poi/util/TestLittleEndianStreams.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/testcases/org/apache/poi/util/TestLittleEndianStreams.java b/src/testcases/org/apache/poi/util/TestLittleEndianStreams.java index 1b327669ae..32373c2be7 100644 --- a/src/testcases/org/apache/poi/util/TestLittleEndianStreams.java +++ b/src/testcases/org/apache/poi/util/TestLittleEndianStreams.java @@ -97,4 +97,30 @@ public final class TestLittleEndianStreams extends TestCase { assertTrue(e.getMessage().contains("Buffer overrun")); } } + + public void testBufferOverrunStartOffset() { + byte[] srcBuf = HexRead.readFromString("99 88 77 88 99"); + LittleEndianInput lei = new LittleEndianByteArrayInputStream(srcBuf, 2); + + // only one byte left, so this should fail + try { + lei.readFully(new byte[4]); + fail("Should catch exception here"); + } catch (RuntimeException e) { + assertTrue(e.getMessage().contains("Buffer overrun")); + } + } + + public void testBufferOverrunStartOffset2() { + byte[] srcBuf = HexRead.readFromString("99 88 77 88 99"); + LittleEndianInput lei = new LittleEndianByteArrayInputStream(srcBuf, 2, 2); + + // only one byte left, so this should fail + try { + lei.readFully(new byte[4]); + fail("Should catch exception here"); + } catch (RuntimeException e) { + assertTrue(e.getMessage().contains("Buffer overrun")); + } + } } |