mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 04:18:53 +01:00
Use @Test annotation to test for exceptions being thrown
Please note that this commit only uses the @Test annotation where exceptions are thrown at the end of the test, because otherwise the test would not be executed completely. Examples for this are in DatabaseComponentImplTest where many exceptions are thrown in close succession or in ConnectionRegistryImplTest where an exception is thrown in the middle of the test.
This commit is contained in:
@@ -20,20 +20,14 @@ public class ByteUtilsTest extends BriarTestCase {
|
||||
assertEquals(65535, ByteUtils.readUint16(b, 1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadUint16ValidatesArguments() {
|
||||
try {
|
||||
ByteUtils.readUint16(new byte[1], 0);
|
||||
fail();
|
||||
} catch (IllegalArgumentException expected) {
|
||||
// Expected
|
||||
}
|
||||
try {
|
||||
ByteUtils.readUint16(new byte[2], 1);
|
||||
fail();
|
||||
} catch (IllegalArgumentException expected) {
|
||||
// Expected
|
||||
}
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testReadUint16ValidatesArguments1() {
|
||||
ByteUtils.readUint16(new byte[1], 0);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testReadUint16ValidatesArguments2() {
|
||||
ByteUtils.readUint16(new byte[2], 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -46,20 +40,14 @@ public class ByteUtilsTest extends BriarTestCase {
|
||||
assertEquals(4294967295L, ByteUtils.readUint32(b, 1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadUint32ValidatesArguments() {
|
||||
try {
|
||||
ByteUtils.readUint32(new byte[3], 0);
|
||||
fail();
|
||||
} catch (IllegalArgumentException expected) {
|
||||
// Expected
|
||||
}
|
||||
try {
|
||||
ByteUtils.readUint32(new byte[4], 1);
|
||||
fail();
|
||||
} catch (IllegalArgumentException expected) {
|
||||
// Expected
|
||||
}
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testReadUint32ValidatesArguments1() {
|
||||
ByteUtils.readUint32(new byte[3], 0);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testReadUint32ValidatesArguments2() {
|
||||
ByteUtils.readUint32(new byte[4], 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user