### Question:
Numbers { public static short safeCastLongToShort( long value ) { if ( (short) value != value ) { throw new ArithmeticException( getOverflowMessage( value, Short.TYPE ) ); } return (short) 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 failSafeCastLongToShort() { expectedException.expect( ArithmeticException.class ); expectedException.expectMessage( "Value 32768 is too big to be represented as short" ); safeCastLongToShort( Short.MAX_VALUE + 1L ); }
@Test void castLongToShort() { assertEquals(1, safeCastLongToShort( 1L )); assertEquals(10, safeCastLongToShort( 10L )); assertEquals(-1, safeCastLongToShort( -1L )); assertEquals(Short.MAX_VALUE, safeCastLongToShort( Short.MAX_VALUE )); assertEquals(Short.MIN_VALUE, safeCastLongToShort( Short.MIN_VALUE )); }