byte[] nobom_utf32le = {0x3C, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03};
byte[] nobom_utf16be = {0x00, 0x3C, 0x00, 0x3F, 0x01, 0x02, 0x03};
byte[] nobom_utf16le = {0x3C, 0x00, 0x3F, 0x00, 0x01, 0x02, 0x03};
ByteArrayInputStream in = new ByteArrayInputStream(utf32be);
CharsetSniffingInputStream csis = new CharsetSniffingInputStream(in);
assertEquals("UTF-32", csis.getEncoding());
assertTrue(csis.isBomSet());
in = new ByteArrayInputStream(utf32le);
csis = new CharsetSniffingInputStream(in);
assertEquals("UTF-32", csis.getEncoding());
assertTrue(csis.isBomSet());
in = new ByteArrayInputStream(utf16be);
csis = new CharsetSniffingInputStream(in);
assertEquals("UTF-16", csis.getEncoding());
assertTrue(csis.isBomSet());
in = new ByteArrayInputStream(utf16le);
csis = new CharsetSniffingInputStream(in);
assertEquals("UTF-16", csis.getEncoding());
assertTrue(csis.isBomSet());
in = new ByteArrayInputStream(utf8);
csis = new CharsetSniffingInputStream(in);
assertEquals("UTF-8", csis.getEncoding());
assertTrue(csis.isBomSet());
in = new ByteArrayInputStream(nobom_utf32be);
csis = new CharsetSniffingInputStream(in);
assertEquals("UTF-32be", csis.getEncoding());
assertFalse(csis.isBomSet());
in = new ByteArrayInputStream(nobom_utf32le);
csis = new CharsetSniffingInputStream(in);
assertEquals("UTF-32le", csis.getEncoding());
assertFalse(csis.isBomSet());
in = new ByteArrayInputStream(nobom_utf16be);
csis = new CharsetSniffingInputStream(in);
assertEquals("UTF-16be", csis.getEncoding());
assertFalse(csis.isBomSet());
in = new ByteArrayInputStream(nobom_utf16le);
csis = new CharsetSniffingInputStream(in);
assertEquals("UTF-16le", csis.getEncoding());
assertFalse(csis.isBomSet());
}