We have a number of tests which can be consolidated, use assertThrows.
This flushes out a bad test case, which is corrected.
Change-Id: I3b0b760cb89a4dbd93ebe44af2ed917b0698fc31
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
b355455a078fbe3043c34bbe4f1ceab39aef11a6)
- public void testNegativeByte() {
+ public void testNegativeValues() {
assertThrows(IllegalArgumentException.class, () -> Uint16.valueOf((byte)-1));
assertThrows(IllegalArgumentException.class, () -> Uint16.valueOf((byte)-1));
- }
-
- @Test
- public void testNegativeShort() {
assertThrows(IllegalArgumentException.class, () -> Uint16.valueOf((short)-1));
assertThrows(IllegalArgumentException.class, () -> Uint16.valueOf((short)-1));
- }
-
- @Test
- public void testNegativeInt() {
assertThrows(IllegalArgumentException.class, () -> Uint16.valueOf(-1));
assertThrows(IllegalArgumentException.class, () -> Uint16.valueOf(-1));
- }
-
- @Test
- public void testNegativeLong() {
assertThrows(IllegalArgumentException.class, () -> Uint16.valueOf(-1L));
}
@Test
assertThrows(IllegalArgumentException.class, () -> Uint16.valueOf(-1L));
}
@Test
- public void testBigInt() {
+ public void testLargeValues() {
assertThrows(IllegalArgumentException.class, () -> Uint16.valueOf(65536));
assertThrows(IllegalArgumentException.class, () -> Uint16.valueOf(65536));
- }
-
- @Test
- public void testBigLong() {
assertThrows(IllegalArgumentException.class, () -> Uint16.valueOf(65536L));
}
assertThrows(IllegalArgumentException.class, () -> Uint16.valueOf(65536L));
}
- public void testNegativeByte() {
+ public void testNegativeValues() {
assertThrows(IllegalArgumentException.class, () -> Uint32.valueOf((byte)-1));
assertThrows(IllegalArgumentException.class, () -> Uint32.valueOf((byte)-1));
- }
-
- @Test
- public void testNegativeShort() {
assertThrows(IllegalArgumentException.class, () -> Uint32.valueOf((short)-1));
assertThrows(IllegalArgumentException.class, () -> Uint32.valueOf((short)-1));
- }
-
- @Test
- public void testNegativeInt() {
assertThrows(IllegalArgumentException.class, () -> Uint32.valueOf(-1));
assertThrows(IllegalArgumentException.class, () -> Uint32.valueOf(-1));
- }
-
- @Test
- public void testNegativeLong() {
assertThrows(IllegalArgumentException.class, () -> Uint32.valueOf(-1L));
}
@Test
assertThrows(IllegalArgumentException.class, () -> Uint32.valueOf(-1L));
}
@Test
- public void testBigLong() {
+ public void testLargeValues() {
assertThrows(IllegalArgumentException.class, () -> Uint32.valueOf(4294967296L));
}
assertThrows(IllegalArgumentException.class, () -> Uint32.valueOf(4294967296L));
}
- public void testNegativeByte() {
+ public void testNegativeValues() {
assertThrows(IllegalArgumentException.class, () -> Uint64.valueOf((byte)-1));
assertThrows(IllegalArgumentException.class, () -> Uint64.valueOf((byte)-1));
- }
-
- @Test
- public void testNegativeShort() {
assertThrows(IllegalArgumentException.class, () -> Uint64.valueOf((short)-1));
assertThrows(IllegalArgumentException.class, () -> Uint64.valueOf((short)-1));
- }
-
- @Test
- public void testNegativeInt() {
assertThrows(IllegalArgumentException.class, () -> Uint64.valueOf(-1));
assertThrows(IllegalArgumentException.class, () -> Uint64.valueOf(-1));
- }
-
- @Test
- public void testNegativeLong() {
assertThrows(IllegalArgumentException.class, () -> Uint64.valueOf(-1L));
assertThrows(IllegalArgumentException.class, () -> Uint64.valueOf(-1L));
- }
-
- @Test
- public void testNegativeBigInteger() {
assertThrows(IllegalArgumentException.class, () -> Uint64.valueOf(new BigInteger("-1")));
}
@Test
assertThrows(IllegalArgumentException.class, () -> Uint64.valueOf(new BigInteger("-1")));
}
@Test
- public void testBigBigInteger() {
- assertThrows(IllegalArgumentException.class, () -> Uint64.valueOf(new BigInteger("0x10000000000000000")));
+ public void testLargeValues() {
+ final BigInteger big = new BigInteger("10000000000000000", 16);
+ assertThrows(IllegalArgumentException.class, () -> Uint64.valueOf(big));
- public void testNullValueOfString() {
+ public void testNullValueOf() {
assertThrows(NullPointerException.class, () -> Uint64.valueOf((String) null));
assertThrows(NullPointerException.class, () -> Uint64.valueOf((String) null));
- }
-
- @Test
- public void testNullValueOfBigInteger() {
assertThrows(NullPointerException.class, () -> Uint64.valueOf((BigInteger) null));
}
}
assertThrows(NullPointerException.class, () -> Uint64.valueOf((BigInteger) null));
}
}
- public void testNegativeByte() {
+ public void testNegativeValues() {
assertThrows(IllegalArgumentException.class, () -> Uint8.valueOf((byte)-1));
assertThrows(IllegalArgumentException.class, () -> Uint8.valueOf((byte)-1));
- }
-
- @Test
- public void testNegativeShort() {
assertThrows(IllegalArgumentException.class, () -> Uint8.valueOf((short)-1));
assertThrows(IllegalArgumentException.class, () -> Uint8.valueOf((short)-1));
- }
-
- @Test
- public void testNegativeInt() {
assertThrows(IllegalArgumentException.class, () -> Uint8.valueOf(-1));
assertThrows(IllegalArgumentException.class, () -> Uint8.valueOf(-1));
- }
-
- @Test
- public void testNegativeLong() {
assertThrows(IllegalArgumentException.class, () -> Uint8.valueOf(-1L));
}
@Test
assertThrows(IllegalArgumentException.class, () -> Uint8.valueOf(-1L));
}
@Test
- public void testBigShort() {
+ public void testLargeValues() {
assertThrows(IllegalArgumentException.class, () -> Uint8.valueOf((short)256));
assertThrows(IllegalArgumentException.class, () -> Uint8.valueOf((short)256));
- }
-
- @Test
- public void testBigInt() {
assertThrows(IllegalArgumentException.class, () -> Uint8.valueOf(256));
assertThrows(IllegalArgumentException.class, () -> Uint8.valueOf(256));
- }
-
- @Test
- public void testBigLong() {
assertThrows(IllegalArgumentException.class, () -> Uint8.valueOf(256L));
}
assertThrows(IllegalArgumentException.class, () -> Uint8.valueOf(256L));
}