private static <T> String toUnsignedString(T v) { if (v instanceof Byte) return intToUnsignedString(byteToUnsignedInt((Byte)v)); else if (v instanceof Short) return intToUnsignedString(shortToUnsignedInt((Short)v)); else if (v instanceof Integer) return intToUnsignedString((Integer)v); else if (v instanceof Long) return longToUnsignedString((Long)v); throw new IllegalArgumentException("Not Range of Byte,Short,Integer, or Long"+v.getClass()); }
@Test public void testToUnsignedString() { testToStringUnsigned(Ranges.open((byte)0,(byte)255), "(0..255)"); testToStringUnsigned(Ranges.closed((byte)0,(byte)255), "[0..255]"); testToStringUnsigned(Ranges.open((short)0,(short)0xFFFF), "(0..65535)"); testToStringUnsigned(Ranges.open(0,0xFFFFFFFF), "(0.."+ intToUnsignedString(0xFFFFFFFF)+")"); testToStringUnsigned(Ranges.open(0L,0xFFFFFFFFFFFFFFFFL), "(0.."+longToUnsignedString(0xFFFFFFFFFFFFFFFFL)+")"); }