### Question:
CharSequenceUtil { public static boolean equals(final CharSequence seq1, final Object obj) { if (seq1 == obj) return true; if (seq1 == null || obj == null) return false; if (!CharSequence.class.isAssignableFrom(obj.getClass())) return false; final CharSequence seq2 = (CharSequence) obj; final int length = seq1.length(); if (length != seq2.length()) return false; for (int i = 0; i < length; i++) { final char ch1 = seq1.charAt(i); final char ch2 = seq2.charAt(i); if (ch1 != ch2) { return false; } } return true; }  static boolean equals(final CharSequence seq1, final Object obj); static int compare(final CharSequence seq1, final CharSequence seq2); static int hashCode(final CharSequence seq);  }### Answer:
@Test public void testNullDoesNotCauseExceptionInEquals() { assertTrue(CharSequenceUtil.equals(null, null)); assertFalse(CharSequenceUtil.equals("", null)); assertFalse(CharSequenceUtil.equals(null, "")); }
@Test public void testEqualSubstring() throws Exception { assertFalse(CharSequenceUtil.equals("", "a")); assertFalse(CharSequenceUtil.equals("a", "")); assertFalse(CharSequenceUtil.equals("ab", "abc")); assertFalse(CharSequenceUtil.equals("abc", "ab")); }
@Test public void testEqualStrings() throws Exception { assertTrue(CharSequenceUtil.equals("abc", "abc")); assertTrue(CharSequenceUtil.equals("", "")); }
@Test public void testEqualIsCaseSensitive() throws Exception { assertFalse(CharSequenceUtil.equals("ABC", "abc")); assertFalse(CharSequenceUtil.equals("abc", "ABC")); }
@Test public void testClassHandling() throws Exception { assertTrue(CharSequenceUtil.equals("abc", new LowerCaseCharSequence("ABC"))); assertTrue(CharSequenceUtil.equals(new LowerCaseCharSequence("ABC"), "abc")); assertFalse(CharSequenceUtil.equals("abc", new Object() {@Override public String toString() { return "abc"; }})); }