remove public access modifier

This commit is contained in:
danielmcnally285 2024-01-01 17:43:08 +00:00
parent c9c82e9e33
commit 441d470b44
1 changed files with 14 additions and 14 deletions

View File

@ -11,79 +11,79 @@ import com.google.common.primitives.Longs;
public class StringToLongPrimitiveOrLongObjectUnitTest { public class StringToLongPrimitiveOrLongObjectUnitTest {
@Test @Test
public void givenString_whenUsingLongConstructor_thenObtainLongObject() { void givenString_whenUsingLongConstructor_thenObtainLongObject() {
Long l = new Long("2147483648"); Long l = new Long("2147483648");
assertThat(l).isEqualTo(2147483648L); assertThat(l).isEqualTo(2147483648L);
} }
@Test @Test
public void givenInvalidString_whenUsingLongConstructor_thenNumberFormatExceptionThrown() { void givenInvalidString_whenUsingLongConstructor_thenNumberFormatExceptionThrown() {
Assertions.assertThrows(NumberFormatException.class, () -> new Long("Invalid String")); Assertions.assertThrows(NumberFormatException.class, () -> new Long("Invalid String"));
} }
@Test @Test
public void givenString_whenUsingLongValueOf_thenObtainLongObject() { void givenString_whenUsingLongValueOf_thenObtainLongObject() {
Long l = Long.valueOf("2147483648"); Long l = Long.valueOf("2147483648");
assertThat(l).isEqualTo(2147483648L); assertThat(l).isEqualTo(2147483648L);
} }
@Test @Test
public void givenInvalidString_whenUsingLongValueOf_thenNumberFormatExceptionThrown() { void givenInvalidString_whenUsingLongValueOf_thenNumberFormatExceptionThrown() {
Assertions.assertThrows(NumberFormatException.class, () -> Long.valueOf("Invalid String")); Assertions.assertThrows(NumberFormatException.class, () -> Long.valueOf("Invalid String"));
} }
@Test @Test
public void givenString_whenUsingParseLong_thenObtainLongPrimitive() { void givenString_whenUsingParseLong_thenObtainLongPrimitive() {
long l = Long.parseLong("2147483648"); long l = Long.parseLong("2147483648");
assertThat(l).isEqualTo(2147483648L); assertThat(l).isEqualTo(2147483648L);
} }
@Test @Test
public void givenInvalidString_whenUsingParseLong_thenNumberFormatExceptionThrown() { void givenInvalidString_whenUsingParseLong_thenNumberFormatExceptionThrown() {
Assertions.assertThrows(NumberFormatException.class, () -> Long.parseLong("Invalid String")); Assertions.assertThrows(NumberFormatException.class, () -> Long.parseLong("Invalid String"));
} }
@Test @Test
public void givenHexadecimalString_whenUsingLongDecode_thenObtainLongObject() { void givenHexadecimalString_whenUsingLongDecode_thenObtainLongObject() {
Long l = Long.decode("0x80000000"); Long l = Long.decode("0x80000000");
assertThat(l).isEqualTo(2147483648L); assertThat(l).isEqualTo(2147483648L);
} }
@Test @Test
public void givenInvalidString_whenUsingLongDecode_thenNumberFormatExceptionThrown() { void givenInvalidString_whenUsingLongDecode_thenNumberFormatExceptionThrown() {
Assertions.assertThrows(NumberFormatException.class, () -> Long.decode("Invalid String")); Assertions.assertThrows(NumberFormatException.class, () -> Long.decode("Invalid String"));
} }
@Test @Test
public void givenHexadecimalString_whenUsingApacheCommonsNumberUtils_thenObtainLongObject() { void givenHexadecimalString_whenUsingApacheCommonsNumberUtils_thenObtainLongObject() {
Long l = NumberUtils.createLong("0x80000000"); Long l = NumberUtils.createLong("0x80000000");
assertThat(l).isEqualTo(2147483648L); assertThat(l).isEqualTo(2147483648L);
} }
@Test @Test
public void givenInvalidString_whenUsingApacheCommonsNumberUtils_thenNumberFormatExceptionThrown() { void givenInvalidString_whenUsingApacheCommonsNumberUtils_thenNumberFormatExceptionThrown() {
Assertions.assertThrows(NumberFormatException.class, () -> NumberUtils.createLong("Invalid String")); Assertions.assertThrows(NumberFormatException.class, () -> NumberUtils.createLong("Invalid String"));
} }
@Test @Test
public void givenString_whenUsingParseUnsignedLong_thenObtainUnsignedLongObject() { void givenString_whenUsingParseUnsignedLong_thenObtainUnsignedLongObject() {
Long l = Long.parseUnsignedLong("9223372036854775808"); Long l = Long.parseUnsignedLong("9223372036854775808");
assertThat(Long.toUnsignedString(l)).isEqualTo("9223372036854775808"); assertThat(Long.toUnsignedString(l)).isEqualTo("9223372036854775808");
} }
@Test @Test
public void givenInvalidString_whenUsingParseUnsignedLong_thenNumberFormatExceptionThrown() { void givenInvalidString_whenUsingParseUnsignedLong_thenNumberFormatExceptionThrown() {
Assertions.assertThrows(NumberFormatException.class, () -> Long.parseUnsignedLong("Invalid String")); Assertions.assertThrows(NumberFormatException.class, () -> Long.parseUnsignedLong("Invalid String"));
} }
@Test @Test
public void givenString_whenUsingGuavaLongs_thenObtainLongObject() { void givenString_whenUsingGuavaLongs_thenObtainLongObject() {
Long l = Longs.tryParse("2147483648"); Long l = Longs.tryParse("2147483648");
assertThat(l).isEqualTo(2147483648L); assertThat(l).isEqualTo(2147483648L);
} }
@Test @Test
public void givenInvalidString_whenUsingGuavaLongs_thenObtainNull() { void givenInvalidString_whenUsingGuavaLongs_thenObtainNull() {
assertThat(Longs.tryParse("Invalid String")).isNull(); assertThat(Longs.tryParse("Invalid String")).isNull();
} }
} }