### Question:
Formats { public static String shortName(String str, int length, int rightLength) { if (str.length() > length) { int leftIndex = length - 3 - rightLength; str = str.substring(0, Math.max(0, leftIndex)) + "..." + str.substring(Math.max(0, str.length() - rightLength), str.length()); } return str; }  static void disableAnsi(); static void setCleanClearTerminal(); static void setTextClearTerminal(); static String toMBWithColor(long bytes, LongWarning warning); static String toColor(long value, LongWarning warning); static String red(String value); static String yellow(String value); static String toMB(long bytes); static String toSizeUnitWithColor(Long size, LongWarning warning); static String toSizeUnit(Long size); static String toFixLengthSizeUnit(Long size); static String toTimeUnit(long millis); static String formatUsage(Usage usage); static String formatUsageWithColor(Usage usage, LongWarning warning); static String[] colorAnsi(long value, LongWarning warning); static String[] colorAnsi(double value, DoubleWarning warning); static String rightStr(String str, int length); static String leftStr(String str, int length); static String shortName(String str, int length, int rightLength); static String join(List<String> list, String delim); static long parseFromSize(String str); static void clearTerminal(); static final long MB_SIZE; static boolean isWindows; }### Answer:
@Test public void shortNameInputNotNullPositivePositiveOutputNotNull() { final String str = "!"; final int length = 1; final int rightLength = 6; final String retval = Formats.shortName(str, length, rightLength); Assert.assertEquals("!", retval); }
@Test public void shortNameInputNotNullPositiveZeroOutputNotNull() { final String str = "!!!!!!!!!!"; final int length = 4; final int rightLength = 0; final String retval = Formats.shortName(str, length, rightLength); Assert.assertEquals("!...", retval); }
@Test public void shortNameInputNotNullZeroNegativeOutputStringIndexOutOfBoundsException() { final String str = "!!!!!!!!!!"; final int length = 0; final int rightLength = -19; thrown.expect(StringIndexOutOfBoundsException.class); Formats.shortName(str, length, rightLength); }