import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import java.math.BigDecimal;
import org.junit.Test;
public class Decimal64Test {
-
- @Test(expected = NumberFormatException.class)
+ @Test
public void testParseEmpty() {
- Decimal64.valueOf("");
+ assertThrows(NumberFormatException.class, () -> Decimal64.valueOf(""));
}
- @Test(expected = NumberFormatException.class)
+ @Test
public void testParseSingleIllegal() {
- Decimal64.valueOf("a");
+ assertThrows(NumberFormatException.class, () -> Decimal64.valueOf("a"));
}
- @Test(expected = NumberFormatException.class)
+ @Test
public void testParseSingleHighIllegal() {
- Decimal64.valueOf(":");
+ assertThrows(NumberFormatException.class, () -> Decimal64.valueOf(":"));
}
- @Test(expected = NumberFormatException.class)
+ @Test
public void testParseZeroIllegal() {
- Decimal64.valueOf("0a");
+ assertThrows(NumberFormatException.class, () -> Decimal64.valueOf("0a"));
}
- @Test(expected = NumberFormatException.class)
+ @Test
public void testParseZeroHighIllegal() {
- Decimal64.valueOf("0:");
+ assertThrows(NumberFormatException.class, () -> Decimal64.valueOf("0:"));
}
- @Test(expected = NumberFormatException.class)
+ @Test
public void testParseZeroPointIllegal() {
- Decimal64.valueOf("0.a");
+ assertThrows(NumberFormatException.class, () -> Decimal64.valueOf("0.a"));
}
- @Test(expected = NumberFormatException.class)
+ @Test
public void testParseZeroPointHighIllegal() {
- Decimal64.valueOf("0.:");
+ assertThrows(NumberFormatException.class, () -> Decimal64.valueOf("0.:"));
}
- @Test(expected = NumberFormatException.class)
+ @Test
public void testParsePointIllegal() {
- Decimal64.valueOf(".a");
+ assertThrows(NumberFormatException.class, () -> Decimal64.valueOf(".a"));
}
- @Test(expected = NumberFormatException.class)
+ @Test
public void testParseMinus() {
- Decimal64.valueOf("-");
+ assertThrows(NumberFormatException.class, () -> Decimal64.valueOf("-"));
}
- @Test(expected = NumberFormatException.class)
+ @Test
public void testParsePlus() {
- Decimal64.valueOf("+");
+ assertThrows(NumberFormatException.class, () -> Decimal64.valueOf("+"));
}
- @Test(expected = NumberFormatException.class)
+ @Test
public void testParsePeriod() {
- Decimal64.valueOf(".");
+ assertThrows(NumberFormatException.class, () -> Decimal64.valueOf("."));
}
- @Test(expected = NumberFormatException.class)
+ @Test
public void testParseTwoPeriods() {
- Decimal64.valueOf("..");
+ assertThrows(NumberFormatException.class, () -> Decimal64.valueOf(".."));
}
- @Test(expected = NumberFormatException.class)
+ @Test
public void testParseTrailingPeriod() {
- Decimal64.valueOf("0.");
+ assertThrows(NumberFormatException.class, () -> Decimal64.valueOf("0."));
}
- @Test(expected = NumberFormatException.class)
+ @Test
public void testParseMultiplePeriods() {
- Decimal64.valueOf("0.1.");
+ assertThrows(NumberFormatException.class, () -> Decimal64.valueOf("0.1."));
}
@Test
Decimal64.valueOf("0.12345678901234568");
}
- @Test(expected = NumberFormatException.class)
+ @Test
public void testParseTooLongString() {
- Decimal64.valueOf("1234567890123456789");
+ assertThrows(NumberFormatException.class, () -> Decimal64.valueOf("1234567890123456789"));
}
- @Test(expected = NumberFormatException.class)
+ @Test
public void testParseTooLongDecimal() {
- Decimal64.valueOf("0.123456789012345689");
+ assertThrows(NumberFormatException.class, () -> Decimal64.valueOf("0.123456789012345689"));
}
@Test
assertEquals(Byte.MAX_VALUE, Decimal64.valueOf(Byte.MAX_VALUE).byteValueExact());
}
- @Test(expected = ArithmeticException.class)
+ @Test
public void testByteValueExactFrac() {
- Decimal64.valueOf("1.1").byteValueExact();
+ final Decimal64 dec = Decimal64.valueOf("1.1");
+ assertThrows(ArithmeticException.class, () -> dec.byteValueExact());
}
- @Test(expected = ArithmeticException.class)
+ @Test
public void testByteValueExactRange() {
- Decimal64.valueOf(Byte.MAX_VALUE + 1).byteValueExact();
+ final Decimal64 dec = Decimal64.valueOf(Byte.MAX_VALUE + 1);
+ assertThrows(ArithmeticException.class, () -> dec.byteValueExact());
}
@Test
assertEquals(Short.MAX_VALUE, Decimal64.valueOf(Short.MAX_VALUE).shortValueExact());
}
- @Test(expected = ArithmeticException.class)
+ @Test
public void testShortValueExactFrac() {
- Decimal64.valueOf("1.1").shortValueExact();
+ final Decimal64 dec = Decimal64.valueOf("1.1");
+ assertThrows(ArithmeticException.class, () -> dec.shortValueExact());
}
- @Test(expected = ArithmeticException.class)
+ @Test
public void testShortValueExactRange() {
- Decimal64.valueOf(Short.MAX_VALUE + 1).shortValueExact();
+ final Decimal64 dec = Decimal64.valueOf(Short.MAX_VALUE + 1);
+ assertThrows(ArithmeticException.class, () -> dec.shortValueExact());
}
@Test
assertEquals(Integer.MAX_VALUE, Decimal64.valueOf(Integer.MAX_VALUE).intValueExact());
}
- @Test(expected = ArithmeticException.class)
+ @Test
public void testIntValueExactFrac() {
- Decimal64.valueOf("1.1").intValueExact();
+ final Decimal64 dec = Decimal64.valueOf("1.1");
+ assertThrows(ArithmeticException.class, () -> dec.intValueExact());
}
- @Test(expected = ArithmeticException.class)
+ @Test
public void testIntValueExactRange() {
- Decimal64.valueOf(Integer.MAX_VALUE + 1L).intValueExact();
+ final Decimal64 dec = Decimal64.valueOf(Integer.MAX_VALUE + 1L);
+ assertThrows(ArithmeticException.class, () -> dec.intValueExact());
}
- @Test(expected = ArithmeticException.class)
+ @Test
public void testLongValueExactFrac() {
- Decimal64.valueOf("1.1").longValueExact();
+ final Decimal64 dec = Decimal64.valueOf("1.1");
+ assertThrows(ArithmeticException.class, () -> dec.longValueExact());
}
private static void assertCanonicalVariants(final String str, final long intPart, final long fracPart,
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream;
assertEquals("2017-12-25", Revision.of("2017-12-25").toString());
}
- @Test(expected = NullPointerException.class)
+ @Test
public void testOfNull() {
- Revision.of(null);
+ assertThrows(NullPointerException.class, () -> Revision.of(null));
}
- @Test(expected = DateTimeParseException.class)
+ @Test
public void testOfEmpty() {
- Revision.of("");
+ assertThrows(DateTimeParseException.class, () -> Revision.of(""));
}
- @Test(expected = DateTimeParseException.class)
+ @Test
public void testOfInvalid() {
- Revision.of("invalid");
+ assertThrows(DateTimeParseException.class, () -> Revision.of("invalid"));
}
- @Test(expected = DateTimeParseException.class)
+ @Test
public void testOfInvalidDate1() {
- Revision.of("2017-13-01");
+ assertThrows(DateTimeParseException.class, () -> Revision.of("2017-13-01"));
}
- @Test(expected = DateTimeParseException.class)
+ @Test
public void testOfInvalidDate2() {
- Revision.of("2017-12-00");
+ assertThrows(DateTimeParseException.class, () -> Revision.of("2017-12-00"));
}
- @Test(expected = DateTimeParseException.class)
+ @Test
public void testOfInvalidDate3() {
- Revision.of("2017-12-32");
+ assertThrows(DateTimeParseException.class, () -> Revision.of("2017-12-32"));
}
@Test
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 java.io.ByteArrayInputStream;
assertEquals(Uint64.valueOf(65535), Uint16.MAX_VALUE.toUint64());
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testToUint8() {
- Uint16.MAX_VALUE.toUint8();
+ assertThrows(IllegalArgumentException.class, () -> Uint16.MAX_VALUE.toUint8());
}
@Test
assertSame(source, read);
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testNegativeByte() {
- Uint16.valueOf((byte)-1);
+ assertThrows(IllegalArgumentException.class, () -> Uint16.valueOf((byte)-1));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testNegativeShort() {
- Uint16.valueOf((short)-1);
+ assertThrows(IllegalArgumentException.class, () -> Uint16.valueOf((short)-1));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testNegativeInt() {
- Uint16.valueOf(-1);
+ assertThrows(IllegalArgumentException.class, () -> Uint16.valueOf(-1));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testNegativeLong() {
- Uint16.valueOf(-1L);
+ assertThrows(IllegalArgumentException.class, () -> Uint16.valueOf(-1L));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testBigInt() {
- Uint16.valueOf(65536);
+ assertThrows(IllegalArgumentException.class, () -> Uint16.valueOf(65536));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testBigLong() {
- Uint16.valueOf(65536L);
+ assertThrows(IllegalArgumentException.class, () -> Uint16.valueOf(65536L));
}
- @Test(expected = NullPointerException.class)
+ @Test
public void testNullValueOfString() {
- Uint16.valueOf((String) null);
+ assertThrows(NullPointerException.class, () -> Uint16.valueOf((String) null));
}
}
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)
+ @Test
public void testNegativeByte() {
- Uint32.valueOf((byte)-1);
+ assertThrows(IllegalArgumentException.class, () -> Uint32.valueOf((byte)-1));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testNegativeShort() {
- Uint32.valueOf((short)-1);
+ assertThrows(IllegalArgumentException.class, () -> Uint32.valueOf((short)-1));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testNegativeInt() {
- Uint32.valueOf(-1);
+ assertThrows(IllegalArgumentException.class, () -> Uint32.valueOf(-1));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testNegativeLong() {
- Uint32.valueOf(-1L);
+ assertThrows(IllegalArgumentException.class, () -> Uint32.valueOf(-1L));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testBigLong() {
- Uint32.valueOf(4294967296L);
+ 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));
}
}
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.UnsignedLong;
assertEquals(Uint32.TEN, Uint64.TEN.toUint32());
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testToUint8() {
- Uint64.MAX_VALUE.toUint8();
+ assertThrows(IllegalArgumentException.class, () -> Uint64.MAX_VALUE.toUint8());
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testToUint16() {
- Uint64.MAX_VALUE.toUint16();
+ assertThrows(IllegalArgumentException.class, () -> Uint64.MAX_VALUE.toUint16());
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testToUint32() {
- Uint64.MAX_VALUE.toUint32();
+ assertThrows(IllegalArgumentException.class, () -> Uint64.MAX_VALUE.toUint32());
}
@Test
assertSame(source, read);
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testNegativeByte() {
- Uint64.valueOf((byte)-1);
+ assertThrows(IllegalArgumentException.class, () -> Uint64.valueOf((byte)-1));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testNegativeShort() {
- Uint64.valueOf((short)-1);
+ assertThrows(IllegalArgumentException.class, () -> Uint64.valueOf((short)-1));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testNegativeInt() {
- Uint64.valueOf(-1);
+ assertThrows(IllegalArgumentException.class, () -> Uint64.valueOf(-1));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testNegativeLong() {
- Uint64.valueOf(-1L);
+ assertThrows(IllegalArgumentException.class, () -> Uint64.valueOf(-1L));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testNegativeBigInteger() {
- Uint64.valueOf(new BigInteger("-1"));
+ assertThrows(IllegalArgumentException.class, () -> Uint64.valueOf(new BigInteger("-1")));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testBigBigInteger() {
- Uint64.valueOf(new BigInteger("0x10000000000000000"));
+ assertThrows(IllegalArgumentException.class, () -> Uint64.valueOf(new BigInteger("0x10000000000000000")));
}
- @Test(expected = NullPointerException.class)
+ @Test
public void testNullValueOfString() {
- Uint64.valueOf((String) null);
+ assertThrows(NullPointerException.class, () -> Uint64.valueOf((String) null));
}
- @Test(expected = NullPointerException.class)
+ @Test
public void testNullValueOfBigInteger() {
- Uint64.valueOf((BigInteger) null);
+ assertThrows(NullPointerException.class, () -> Uint64.valueOf((BigInteger) null));
}
}
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 java.io.ByteArrayInputStream;
assertSame(source, read);
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testNegativeByte() {
- Uint8.valueOf((byte)-1);
+ assertThrows(IllegalArgumentException.class, () -> Uint8.valueOf((byte)-1));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testNegativeShort() {
- Uint8.valueOf((short)-1);
+ assertThrows(IllegalArgumentException.class, () -> Uint8.valueOf((short)-1));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testNegativeInt() {
- Uint8.valueOf(-1);
+ assertThrows(IllegalArgumentException.class, () -> Uint8.valueOf(-1));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testNegativeLong() {
- Uint8.valueOf(-1L);
+ assertThrows(IllegalArgumentException.class, () -> Uint8.valueOf(-1L));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testBigShort() {
- Uint8.valueOf((short)256);
+ assertThrows(IllegalArgumentException.class, () -> Uint8.valueOf((short)256));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testBigInt() {
- Uint8.valueOf(256);
+ assertThrows(IllegalArgumentException.class, () -> Uint8.valueOf(256));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testBigLong() {
- Uint8.valueOf(256L);
+ assertThrows(IllegalArgumentException.class, () -> Uint8.valueOf(256L));
}
- @Test(expected = NullPointerException.class)
+ @Test
public void testNullValueOfString() {
- Uint8.valueOf((String) null);
+ assertThrows(NullPointerException.class, () -> Uint8.valueOf((String) null));
}
}
package org.opendaylight.yangtools.yang.common;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThrows;
import java.util.AbstractMap.SimpleImmutableEntry;
import org.junit.Test;
assertEquals(new SimpleImmutableEntry<>("foo@bar", "baz"), YangNames.parseFilename("foo@bar@baz"));
}
- @Test(expected = NullPointerException.class)
+ @Test
public void testParseFileNameNull() {
- YangNames.parseFilename(null);
+ assertThrows(NullPointerException.class, () -> YangNames.parseFilename(null));
}
}
package org.opendaylight.yangtools.yang.common;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThrows;
import java.util.Optional;
import org.junit.Test;
assertEquals(Optional.of(YangVersion.VERSION_1_1), YangVersion.parse("1.1"));
}
- @Test(expected = NullPointerException.class)
+ @Test
public void testParseNull() {
- YangVersion.parse(null);
+ assertThrows(NullPointerException.class, () -> YangVersion.parse(null));
}
@Test