Skip to content

Commit 9de55e6

Browse files
committed
DataHandleTest: make checkLength in testReading optional
Some handles don't know their length, so we need an option to skip the the length check.
1 parent 2f54eed commit 9de55e6

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/test/java/org/scijava/io/handle/DataHandleTest.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public void testEndianesSettings() throws IOException {
113113
@Test
114114
public void testReading() throws IOException {
115115
try (final DataHandle<? extends Location> handle = createHandle()) {
116-
checkBasicReadMethods(handle);
116+
checkBasicReadMethods(handle, true);
117117
checkEndiannessReading(handle);
118118
}
119119
}
@@ -168,13 +168,16 @@ public void populateData(final OutputStream out) throws IOException {
168168
* Checks basic byte reading methods.
169169
*
170170
* @param handle the handle to test
171+
* @param checkLength whether to check the total length of the handle
171172
* @throws IOException
172173
*/
173174
public <L extends Location> void checkBasicReadMethods(
174-
final DataHandle<L> handle) throws IOException
175+
final DataHandle<L> handle, boolean checkLength) throws IOException
175176
{
176177
assertEquals(0, handle.offset());
177-
assertEquals(BYTES.length, handle.length());
178+
if (checkLength) {
179+
assertEquals(BYTES.length, handle.length());
180+
}
178181
assertEquals("UTF-8", handle.getEncoding());
179182

180183
// test read()

src/test/java/org/scijava/io/handle/ReadBufferDataHandleTest.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public void testSmallBuffer() throws IOException {
6464
new ReadBufferDataHandle(handle, 5))
6565
{
6666
// check with small buffersize
67-
checkBasicReadMethods(bufferedHandle);
67+
checkBasicReadMethods(bufferedHandle, true);
6868
checkEndiannessReading(bufferedHandle);
6969
}
7070
}
@@ -127,7 +127,6 @@ public void testLargeRead() throws Exception {
127127
}
128128

129129
@Test
130-
@Ignore
131130
@Override
132131
public void testWriting() throws IOException {
133132
// nothing to do here

src/test/java/org/scijava/io/handle/WriteBufferDataHandleTest.java

-2
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,12 @@ public DataHandle<? extends Location> createHandle() {
6464
}
6565

6666
@Test
67-
@Ignore
6867
@Override
6968
public void testReading() throws IOException {
7069
// nothing to do
7170
}
7271

7372
@Test
74-
@Ignore
7573
@Override
7674
public void checkSkip() throws IOException {
7775
// nothing to do

0 commit comments

Comments
 (0)