mirror of
https://github.com/kiwix/java-libkiwix.git
synced 2025-09-12 00:27:46 -04:00
Testing of JNIKiwixReader.getDirectAccessInformation()
This commit is contained in:
parent
ec52bfb1f8
commit
ae58f42b6c
@ -22,6 +22,19 @@ throws IOException
|
||||
return data;
|
||||
}
|
||||
|
||||
private static byte[] getFileContentPartial(String path, int offset, int size)
|
||||
throws IOException
|
||||
{
|
||||
File file = new File(path);
|
||||
DataInputStream in = new DataInputStream(
|
||||
new BufferedInputStream(
|
||||
new FileInputStream(file)));
|
||||
byte[] data = new byte[size];
|
||||
in.skipBytes(offset);
|
||||
in.read(data, 0, size);
|
||||
return data;
|
||||
}
|
||||
|
||||
private static String getTextFileContent(String path)
|
||||
throws IOException
|
||||
{
|
||||
@ -50,6 +63,11 @@ throws JNIKiwixException, IOException
|
||||
new JNIKiwixString(),
|
||||
new JNIKiwixInt());
|
||||
assertTrue(Arrays.equals(faviconData, c));
|
||||
|
||||
DirectAccessInfo dai = reader.getDirectAccessInformation("I/favicon.png");
|
||||
assertNotEquals("", dai.filename);
|
||||
c = getFileContentPartial(dai.filename, (int)dai.offset, faviconData.length);
|
||||
assertTrue(Arrays.equals(faviconData, c));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -75,6 +93,11 @@ throws JNIKiwixException, IOException
|
||||
new JNIKiwixString(),
|
||||
new JNIKiwixInt());
|
||||
assertTrue(Arrays.equals(faviconData, c));
|
||||
|
||||
DirectAccessInfo dai = reader.getDirectAccessInformation("I/favicon.png");
|
||||
assertNotEquals("", dai.filename);
|
||||
c = getFileContentPartial(dai.filename, (int)dai.offset, faviconData.length);
|
||||
assertTrue(Arrays.equals(faviconData, c));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -101,6 +124,11 @@ throws JNIKiwixException, IOException
|
||||
new JNIKiwixString(),
|
||||
new JNIKiwixInt());
|
||||
assertTrue(Arrays.equals(faviconData, c));
|
||||
|
||||
DirectAccessInfo dai = reader.getDirectAccessInformation("I/favicon.png");
|
||||
assertNotEquals("", dai.filename);
|
||||
c = getFileContentPartial(dai.filename, (int)dai.offset, faviconData.length);
|
||||
assertTrue(Arrays.equals(faviconData, c));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
x
Reference in New Issue
Block a user