### Question:
UnicodeBom { public static String toString(byte[] input) { if (input.length >= 3 && input[0] == X_EF && input[1] == X_BB && input[2] == X_BF) { return new String(input, 3, input.length - 3, StandardCharsets.UTF_8); } else if (input.length >= 2 && input[0] == X_FE && input[1] == X_FF) { return new String(input, 2, input.length - 2, StandardCharsets.UTF_16BE); } else if (input.length >= 2 && input[0] == X_FF && input[1] == X_FE) { return new String(input, 2, input.length - 2, StandardCharsets.UTF_16LE); } else { return new String(input, StandardCharsets.UTF_8); } } private  UnicodeBom(); static String toString(byte[] input); static CharSource toCharSource(ByteSource byteSource); static Reader toReader(InputStream inputStream);  }### Answer:
@Test public void test_toString_noBomUtf8() throws IOException { byte[] bytes = {'H', 'e', 'l', 'l', 'o'}; String str = UnicodeBom.toString(bytes); assertThat(str).isEqualTo("Hello"); }
@Test public void test_toString_bomUtf8() throws IOException { byte[] bytes = {(byte) 0xEF, (byte) 0xBB, (byte) 0xBF, 'H', 'e', 'l', 'l', 'o'}; String str = UnicodeBom.toString(bytes); assertThat(str).isEqualTo("Hello"); }
@Test public void test_toString_bomUtf16BE() throws IOException { byte[] bytes = {X_FE, X_FF, X_00, 'H', X_00, 'e', X_00, 'l', X_00, 'l', X_00, 'o'}; String str = UnicodeBom.toString(bytes); assertThat(str).isEqualTo("Hello"); }
@Test public void test_toString_bomUtf16LE() throws IOException { byte[] bytes = {X_FF, X_FE, 'H', X_00, 'e', X_00, 'l', X_00, 'l', X_00, 'o', X_00}; String str = UnicodeBom.toString(bytes); assertThat(str).isEqualTo("Hello"); }