Begin work on DataFile

This commit is contained in:
Adam
2015-10-12 20:34:53 -04:00
parent c9a0c7bc55
commit 07af5cef90
3 changed files with 250 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
package net.runelite.cache.fs;
import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
import org.junit.Assert;
import org.junit.Test;
public class DataFileTest
{
@Test
public void test1() throws IOException
{
File file = new File("d:/rs/07/test/test.dat");
DataFile df = new DataFile(42, file);
int sector = df.write(3, ByteBuffer.wrap("test".getBytes()));
ByteBuffer buf = df.read(3, sector, 4);
String str = new String(buf.array());
Assert.assertEquals("test", str);
file.delete();
}
@Test
public void test2() throws IOException
{
byte[] b = new byte[1024];
for (int i = 0; i < 1024; ++i) b[i] = (byte) i;
File file = new File("d:/rs/07/test/test.dat");
DataFile df = new DataFile(42, file);
int sector = df.write(0x1FFFF, ByteBuffer.wrap(b));
ByteBuffer buf = df.read(0x1FFFF, sector, b.length);
Assert.assertArrayEquals(b, buf.array());
file.delete();
}
}