import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import com.google.common.primitives.UnsignedInteger;
assertEquals(Uint64.valueOf(4294967295L), Uint32.MAX_VALUE.toUint64());
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testToUint8() {
- Uint32.MAX_VALUE.toUint8();
+ assertThrows(IllegalArgumentException.class, () -> Uint32.MAX_VALUE.toUint8());
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testToUint16() {
- Uint32.MAX_VALUE.toUint16();
+ assertThrows(IllegalArgumentException.class, () -> Uint32.MAX_VALUE.toUint16());
}
@Test
assertSame(source, read);
}
- @Test(expected = IllegalArgumentException.class)
- public void testNegativeByte() {
- Uint32.valueOf((byte)-1);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testNegativeShort() {
- Uint32.valueOf((short)-1);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testNegativeInt() {
- Uint32.valueOf(-1);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testNegativeLong() {
- Uint32.valueOf(-1L);
+ @Test
+ public void testNegativeValues() {
+ assertThrows(IllegalArgumentException.class, () -> Uint32.valueOf((byte)-1));
+ assertThrows(IllegalArgumentException.class, () -> Uint32.valueOf((short)-1));
+ assertThrows(IllegalArgumentException.class, () -> Uint32.valueOf(-1));
+ assertThrows(IllegalArgumentException.class, () -> Uint32.valueOf(-1L));
}
- @Test(expected = IllegalArgumentException.class)
- public void testBigLong() {
- Uint32.valueOf(4294967296L);
+ @Test
+ public void testLargeValues() {
+ assertThrows(IllegalArgumentException.class, () -> Uint32.valueOf(4294967296L));
}
- @Test(expected = NullPointerException.class)
+ @Test
public void testNullValueOfString() {
- Uint32.valueOf((String) null);
+ assertThrows(NullPointerException.class, () -> Uint32.valueOf((String) null));
}
}