Skip to content

Commit

Permalink
DataHandleTest: make checkLength in testReading optional
Browse files Browse the repository at this point in the history
Some handles don't know their length, so we need an option to skip the
the length check.
  • Loading branch information
gab1one committed Oct 16, 2018
1 parent 2f54eed commit 9de55e6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
9 changes: 6 additions & 3 deletions src/test/java/org/scijava/io/handle/DataHandleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public void testEndianesSettings() throws IOException {
@Test
public void testReading() throws IOException {
try (final DataHandle<? extends Location> handle = createHandle()) {
checkBasicReadMethods(handle);
checkBasicReadMethods(handle, true);
checkEndiannessReading(handle);
}
}
Expand Down Expand Up @@ -168,13 +168,16 @@ public void populateData(final OutputStream out) throws IOException {
* Checks basic byte reading methods.
*
* @param handle the handle to test
* @param checkLength whether to check the total length of the handle
* @throws IOException
*/
public <L extends Location> void checkBasicReadMethods(
final DataHandle<L> handle) throws IOException
final DataHandle<L> handle, boolean checkLength) throws IOException
{
assertEquals(0, handle.offset());
assertEquals(BYTES.length, handle.length());
if (checkLength) {
assertEquals(BYTES.length, handle.length());
}
assertEquals("UTF-8", handle.getEncoding());

// test read()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void testSmallBuffer() throws IOException {
new ReadBufferDataHandle(handle, 5))
{
// check with small buffersize
checkBasicReadMethods(bufferedHandle);
checkBasicReadMethods(bufferedHandle, true);
checkEndiannessReading(bufferedHandle);
}
}
Expand Down Expand Up @@ -127,7 +127,6 @@ public void testLargeRead() throws Exception {
}

@Test
@Ignore
@Override
public void testWriting() throws IOException {
// nothing to do here
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,12 @@ public DataHandle<? extends Location> createHandle() {
}

@Test
@Ignore
@Override
public void testReading() throws IOException {
// nothing to do
}

@Test
@Ignore
@Override
public void checkSkip() throws IOException {
// nothing to do
Expand Down

0 comments on commit 9de55e6

Please sign in to comment.