Skip to content

Commit

Permalink
available should report stuff in the buffer as well
Browse files Browse the repository at this point in the history
  • Loading branch information
markrileybot committed Oct 23, 2017
1 parent 160cbbd commit d1bbe04
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ repositories {
}

group = 'com.github.markrileybot.heatshrink'
version = '0.1.0'
version = '0.1.1'

dependencies {
testCompile 'junit:junit:4.12'
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.2.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.2.1-all.zip
2 changes: 1 addition & 1 deletion src/main/java/heatshrink/HsInputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ public long skipRaw(long n) throws IOException {
* @exception IOException if an I/O error occurs.
*/
public int available() throws IOException {
return in.available();
return inputBufferLen - inputBufferPos + in.available();
}

/**
Expand Down
4 changes: 4 additions & 0 deletions src/test/java/heatshrink/HsInputStreamTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ public void testAvailable() throws IOException {
try(HsInputStream hsi = new HsInputStream(new ByteArrayInputStream(new byte[] {1,2,3}))) {
Assert.assertEquals(3, hsi.available());
}
try(HsInputStream hsi = new HsInputStream(new ByteArrayInputStream(new byte[] {1,2,3}))) {
hsi.ensureAvailable(16);
Assert.assertEquals(3, hsi.available());
}
}

@Test
Expand Down

0 comments on commit d1bbe04

Please sign in to comment.