mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-24 21:20:45 +00:00
Removed try/catch blocks from tests: exceptions are well managed by JUnit
This commit is contained in:
@@ -23,156 +23,118 @@ public class TestSWFStream extends TestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFB() {
|
||||
try {
|
||||
double f = 5.25;
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
SWFOutputStream sos = new SWFOutputStream(baos, 10);
|
||||
sos.writeFB(20, f);
|
||||
sos.close();
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
|
||||
SWFInputStream sis = new SWFInputStream(bais, 10);
|
||||
assertTrue(Double.compare(f, sis.readFB(20)) == 0);
|
||||
sis.close();
|
||||
} catch (IOException e) {
|
||||
fail();
|
||||
}
|
||||
public void testFB() throws IOException {
|
||||
double f = 5.25;
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
SWFOutputStream sos = new SWFOutputStream(baos, 10);
|
||||
sos.writeFB(20, f);
|
||||
sos.close();
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
|
||||
SWFInputStream sis = new SWFInputStream(bais, 10);
|
||||
assertTrue(Double.compare(f, sis.readFB(20)) == 0);
|
||||
sis.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUB() {
|
||||
try {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
SWFOutputStream sos = new SWFOutputStream(baos, 10);
|
||||
sos.writeUB(5, 1);
|
||||
sos.writeUB(6, 2);
|
||||
sos.writeUB(7, 3);
|
||||
sos.writeUB(8, 4);
|
||||
sos.writeUB(9, 5);
|
||||
sos.close();
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
|
||||
SWFInputStream sis = new SWFInputStream(bais, 10);
|
||||
assertEquals(1, sis.readUB(5));
|
||||
assertEquals(2, sis.readUB(6));
|
||||
assertEquals(3, sis.readUB(7));
|
||||
assertEquals(4, sis.readUB(8));
|
||||
assertEquals(5, sis.readUB(9));
|
||||
sis.close();
|
||||
} catch (IOException e) {
|
||||
fail();
|
||||
}
|
||||
public void testUB() throws IOException {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
SWFOutputStream sos = new SWFOutputStream(baos, 10);
|
||||
sos.writeUB(5, 1);
|
||||
sos.writeUB(6, 2);
|
||||
sos.writeUB(7, 3);
|
||||
sos.writeUB(8, 4);
|
||||
sos.writeUB(9, 5);
|
||||
sos.close();
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
|
||||
SWFInputStream sis = new SWFInputStream(bais, 10);
|
||||
assertEquals(1, sis.readUB(5));
|
||||
assertEquals(2, sis.readUB(6));
|
||||
assertEquals(3, sis.readUB(7));
|
||||
assertEquals(4, sis.readUB(8));
|
||||
assertEquals(5, sis.readUB(9));
|
||||
sis.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSB() {
|
||||
try {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
SWFOutputStream sos = new SWFOutputStream(baos, 10);
|
||||
sos.writeSB(5, -1);
|
||||
sos.writeSB(6, 2);
|
||||
sos.writeSB(7, -3);
|
||||
sos.writeSB(8, 4);
|
||||
sos.writeSB(9, -5);
|
||||
sos.close();
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
|
||||
SWFInputStream sis = new SWFInputStream(bais, 10);
|
||||
assertEquals(-1, sis.readSB(5));
|
||||
assertEquals(2, sis.readSB(6));
|
||||
assertEquals(-3, sis.readSB(7));
|
||||
assertEquals(4, sis.readSB(8));
|
||||
assertEquals(-5, sis.readSB(9));
|
||||
sis.close();
|
||||
} catch (IOException e) {
|
||||
fail();
|
||||
}
|
||||
public void testSB() throws IOException {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
SWFOutputStream sos = new SWFOutputStream(baos, 10);
|
||||
sos.writeSB(5, -1);
|
||||
sos.writeSB(6, 2);
|
||||
sos.writeSB(7, -3);
|
||||
sos.writeSB(8, 4);
|
||||
sos.writeSB(9, -5);
|
||||
sos.close();
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
|
||||
SWFInputStream sis = new SWFInputStream(bais, 10);
|
||||
assertEquals(-1, sis.readSB(5));
|
||||
assertEquals(2, sis.readSB(6));
|
||||
assertEquals(-3, sis.readSB(7));
|
||||
assertEquals(4, sis.readSB(8));
|
||||
assertEquals(-5, sis.readSB(9));
|
||||
sis.close();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testFLOATAndDouble() {
|
||||
try {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
SWFOutputStream sos = new SWFOutputStream(baos, 10);
|
||||
float f = 5.25f;
|
||||
sos.writeFLOAT(f);
|
||||
sos.close();
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
|
||||
SWFInputStream sis = new SWFInputStream(bais, 10);
|
||||
assertEquals(f, sis.readFLOAT());
|
||||
sis.close();
|
||||
} catch (IOException e) {
|
||||
fail();
|
||||
}
|
||||
public void testFLOATAndDouble() throws IOException {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
SWFOutputStream sos = new SWFOutputStream(baos, 10);
|
||||
float f = 5.25f;
|
||||
sos.writeFLOAT(f);
|
||||
sos.close();
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
|
||||
SWFInputStream sis = new SWFInputStream(bais, 10);
|
||||
assertEquals(f, sis.readFLOAT());
|
||||
sis.close();
|
||||
|
||||
try {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
SWFOutputStream sos = new SWFOutputStream(baos, 10);
|
||||
float f = 5.25f;
|
||||
sos.writeFLOAT16(f);
|
||||
sos.close();
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
|
||||
SWFInputStream sis = new SWFInputStream(bais, 10);
|
||||
assertEquals(f, sis.readFLOAT16());
|
||||
sis.close();
|
||||
} catch (IOException e) {
|
||||
fail();
|
||||
}
|
||||
baos = new ByteArrayOutputStream();
|
||||
sos = new SWFOutputStream(baos, 10);
|
||||
f = 5.25f;
|
||||
sos.writeFLOAT16(f);
|
||||
sos.close();
|
||||
bais = new ByteArrayInputStream(baos.toByteArray());
|
||||
sis = new SWFInputStream(bais, 10);
|
||||
assertEquals(f, sis.readFLOAT16());
|
||||
sis.close();
|
||||
|
||||
try {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
SWFOutputStream sos = new SWFOutputStream(baos, 10);
|
||||
double d = 5.25;
|
||||
sos.writeDOUBLE(d);
|
||||
sos.close();
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
|
||||
SWFInputStream sis = new SWFInputStream(bais, 10);
|
||||
assertEquals(d, sis.readDOUBLE());
|
||||
sis.close();
|
||||
} catch (IOException e) {
|
||||
fail();
|
||||
}
|
||||
baos = new ByteArrayOutputStream();
|
||||
sos = new SWFOutputStream(baos, 10);
|
||||
double d = 5.25;
|
||||
sos.writeDOUBLE(d);
|
||||
sos.close();
|
||||
bais = new ByteArrayInputStream(baos.toByteArray());
|
||||
sis = new SWFInputStream(bais, 10);
|
||||
assertEquals(d, sis.readDOUBLE());
|
||||
sis.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFIXEDandFIXED8() {
|
||||
public void testFIXEDandFIXED8() throws IOException {
|
||||
//example from specification
|
||||
try {
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(new byte[]{(byte) 0x00, (byte) 0x80, (byte) 0x07, (byte) 0x00});
|
||||
SWFInputStream sis = new SWFInputStream(bais, 10);
|
||||
assertTrue(Double.compare(7.5, sis.readFIXED()) == 0);
|
||||
sis.close();
|
||||
} catch (IOException e) {
|
||||
fail();
|
||||
}
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(new byte[]{(byte) 0x00, (byte) 0x80, (byte) 0x07, (byte) 0x00});
|
||||
SWFInputStream sis = new SWFInputStream(bais, 10);
|
||||
assertTrue(Double.compare(7.5, sis.readFIXED()) == 0);
|
||||
sis.close();
|
||||
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
SWFOutputStream sos = new SWFOutputStream(baos, 10);
|
||||
double dd = 5.25;
|
||||
sos.writeFIXED(dd);
|
||||
sos.close();
|
||||
bais = new ByteArrayInputStream(baos.toByteArray());
|
||||
sis = new SWFInputStream(bais, 10);
|
||||
assertTrue(Double.compare(dd, sis.readFIXED()) == 0);
|
||||
sis.close();
|
||||
|
||||
try {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
SWFOutputStream sos = new SWFOutputStream(baos, 10);
|
||||
double f = 5.25;
|
||||
sos.writeFIXED(f);
|
||||
sos.close();
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
|
||||
SWFInputStream sis = new SWFInputStream(bais, 10);
|
||||
assertTrue(Double.compare(f, sis.readFIXED()) == 0);
|
||||
sis.close();
|
||||
} catch (IOException e) {
|
||||
fail();
|
||||
}
|
||||
|
||||
try {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
SWFOutputStream sos = new SWFOutputStream(baos, 10);
|
||||
float f = 5.25f;
|
||||
sos.writeFIXED8(f);
|
||||
sos.close();
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
|
||||
SWFInputStream sis = new SWFInputStream(bais, 10);
|
||||
assertEquals(f, sis.readFIXED8());
|
||||
sis.close();
|
||||
} catch (IOException e) {
|
||||
fail();
|
||||
}
|
||||
|
||||
baos = new ByteArrayOutputStream();
|
||||
sos = new SWFOutputStream(baos, 10);
|
||||
float ff = 5.25f;
|
||||
sos.writeFIXED8(ff);
|
||||
sos.close();
|
||||
bais = new ByteArrayInputStream(baos.toByteArray());
|
||||
sis = new SWFInputStream(bais, 10);
|
||||
assertEquals(ff, sis.readFIXED8());
|
||||
sis.close();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user