### Question:
Numbers { public static short safeCastIntToUnsignedShort( int value ) { if ( (value & ~0xFFFF) != 0 ) { throw new ArithmeticException( getOverflowMessage( value, "unsigned short" ) ); } 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 failSafeCastIntToUnsignedShort() { expectedException.expect( ArithmeticException.class ); expectedException.expectMessage( "Value 131068 is too big to be represented as unsigned short" ); safeCastIntToUnsignedShort( Short.MAX_VALUE << 2 ); }
@Test void castIntToUnsignedShort() { assertEquals(1, safeCastIntToUnsignedShort( 1 )); assertEquals(10, safeCastIntToUnsignedShort( 10 )); assertEquals( -1, safeCastIntToUnsignedShort( (Short.MAX_VALUE << 1) + 1 ) ); }