public void testCopyHeapCharBuffer() { String s = "abcde"; CharBuffer buffer = CharBuffer.allocate(s.length()); buffer.append(s); buffer.rewind(); assertNotNull(CharArrayUtil.fromSequenceWithoutCopying(buffer)); assertNotNull(CharArrayUtil.fromSequenceWithoutCopying(buffer.subSequence(0, 5))); // assertNull(CharArrayUtil.fromSequenceWithoutCopying(buffer.subSequence(0, 4))); // end index // is not checked assertNull(CharArrayUtil.fromSequenceWithoutCopying(buffer.subSequence(1, 5))); assertNull(CharArrayUtil.fromSequenceWithoutCopying(buffer.subSequence(1, 2))); }