### Question:
StringUtil { public static String formatSize(double size) { int rank = 0; String rankchar = "Bytes"; while (size > 1024) { size = size / 1024; rank++; } switch (rank) { case 1: rankchar = "KB"; break; case 2: rankchar = "MB"; break; case 3: rankchar = "GB"; break; default: rankchar = "B"; } return new DecimalFormat("0.##").format(size) + " " + rankchar; }  static String getMiddleString(String text, String lStr, String rStr); static String deleteCRLFOnce(String input); static String str2HexStr(String str); static String hexStr2Str(String hexStr); static String byte2HexStr(byte[] b); static byte[] hexStr2Bytes(String src); static String str2Unicode(String strText); static String unicode2Str(String hex); static String delTagsFContent(String content); static String formatSize(double size); static String getEncoding(byte[] bytes); static List<Node> getFileList(Torrent torrent); static CodepageDetectorProxy detector; }### Answer:
@Test public void testFormatSize() { assertEquals("512 GB", StringUtil.formatSize(0x1p+39)); assertEquals("16 MB", StringUtil.formatSize(0x1p+24)); assertEquals("1024 KB", StringUtil.formatSize(0x1p+20)); assertEquals("4 B", StringUtil.formatSize(0x1p+72)); }