### Question:
Numbers { public static int safeCastLongToInt( long value ) { if ( (int) value != value ) { throw new ArithmeticException( getOverflowMessage( value, Integer.TYPE ) ); } return (int) value; }  static boolean isPowerOfTwo( long value ); static int log2floor( long value ); static short safeCastIntToUnsignedShort( int value ); static byte safeCastIntToUnsignedByte( int value ); static int safeCastLongToInt( long value ); static short safeCastLongToShort( long value ); static short safeCastIntToShort( int value ); static byte safeCastLongToByte( long value ); static int unsignedShortToInt( short value ); static int unsignedByteToInt( byte value );  }### Answer:
@Test void failSafeCastLongToInt() { expectedException.expect( ArithmeticException.class ); expectedException.expectMessage( "Value 2147483648 is too big to be represented as int" ); safeCastLongToInt( Integer.MAX_VALUE + 1L ); }
@Test void castLongToInt() { assertEquals(1, safeCastLongToInt( 1L )); assertEquals(10, safeCastLongToInt( 10L )); assertEquals(-1, safeCastLongToInt( -1L )); assertEquals(Integer.MAX_VALUE, safeCastLongToInt( Integer.MAX_VALUE )); assertEquals(Integer.MIN_VALUE, safeCastLongToInt( Integer.MIN_VALUE )); }