gt:       assertEquals(0, CharSequences.indexOf("abc", 'a'));
context: /**
   * Created By: cfloersch
   * Date: 6/9/13
   * Copyright 2013 XpertSoftware
   */
  package xpertss.lang;
  
  import org.junit.Test;
  
  import static junit.framework.Assert.assertEquals;
  import static junit.framework.Assert.assertFalse;
  import static junit.framework.Assert.assertTrue;
  import static junit.framework.Assert.assertNull;
  
  public class CharSequencesTest {
  
  
     @Test
     public void testLength()
     {
        assertEquals(0, CharSequences.length(null));
        assertEquals(0, CharSequences.length(""));
        assertEquals(3, CharSequences.length("abc"));
     }
  
     @Test
     public void testTrim()
     {
        assertNull(CharSequences.trim(null));
        assertEquals("", CharSequences.trim(""));
        assertEquals("", CharSequences.trim(" "));
        assertEquals("", CharSequences.trim("  "));
        assertEquals("abc", CharSequences.trim("abc"));
        assertEquals("abc", CharSequences.trim(" abc"));
        assertEquals("abc", CharSequences.trim("abc "));
        assertEquals("abc", CharSequences.trim(" abc "));
        assertEquals("abc", CharSequences.trim("\tabc\n"));
        assertEquals("abc", CharSequences.trim("\tabc\r\n"));
        assertEquals("abc", CharSequences.trim("\tabc\r"));
        assertEquals("abc", CharSequences.trim("\t abc\r"));
        assertEquals("abc", CharSequences.trim("\tabc \r"));
        assertEquals("abc", CharSequences.trim("\tabc\r "));
        assertEquals("abc", CharSequences.trim(" \tabc\r"));
        assertEquals("abc", CharSequences.trim("\t abc\t "));
     }
  
  
     @Test
     public void testContains()
     {
        assertFalse(CharSequences.contains(null,null));
        assertFalse(CharSequences.contains(null,"hello"));
        assertFalse(CharSequences.contains("hello",null));
        assertFalse(CharSequences.contains("hello","hi"));
        assertTrue(CharSequences.contains("hello", "hell"));
     }
  
  
     @Test
     public void testEqual()
     {
        assertTrue(CharSequences.equal(null, null));
        assertFalse(CharSequences.equal(null, "abc"));
        assertFalse(CharSequences.equal("abc", null));
        assertTrue(CharSequences.equal("abc", "abc"));
        assertFalse(CharSequences.equal("abc", "ABC"));
        assertTrue(CharSequences.equal("abc", new StringBuilder("abc")));
        assertTrue(CharSequences.equal("abc", new StringBuffer("abc")));
        assertTrue(CharSequences.equal(new StringBuilder("abc"), "abc"));
        assertTrue(CharSequences.equal(new StringBuffer("abc"), "abc"));
        assertFalse(CharSequences.equal("abc", new StringBuilder("ABC")));
        assertFalse(CharSequences.equal("abc", new StringBuffer("ABC")));
        assertFalse(CharSequences.equal(new StringBuilder("ABC"), "abc"));
        assertFalse(CharSequences.equal(new StringBuffer("ABC"), "abc"));
     }
  
     @Test
     public void testEqualIgnoreCase()
     {
        assertTrue(CharSequences.equalIgnoreCase(null, null));
        assertFalse(CharSequences.equalIgnoreCase(null, "abc"));
        assertFalse(CharSequences.equalIgnoreCase("abc", null));
        assertTrue(CharSequences.equalIgnoreCase("abc", "abc"));
        assertTrue(CharSequences.equalIgnoreCase("abc", "ABC"));
        assertTrue(CharSequences.equalIgnoreCase("abc", new StringBuilder("abc")));
        assertTrue(CharSequences.equalIgnoreCase("abc", new StringBuffer("abc")));
        assertTrue(CharSequences.equalIgnoreCase(new StringBuilder("abc"), "abc"));
        assertTrue(CharSequences.equalIgnoreCase(new StringBuffer("abc"), "abc"));
        assertTrue(CharSequences.equalIgnoreCase("abc", new StringBuilder("ABC")));
        assertTrue(CharSequences.equalIgnoreCase("abc", new StringBuffer("ABC")));
        assertTrue(CharSequences.equalIgnoreCase(new StringBuilder("ABC"), "abc"));
        assertTrue(CharSequences.equalIgnoreCase(new StringBuffer("ABC"), "abc"));
  
        assertFalse(CharSequences.equalIgnoreCase("abc", "efg"));
        assertFalse(CharSequences.equalIgnoreCase("abc", "EFG"));
        assertFalse(CharSequences.equalIgnoreCase("abc", ""));
        assertFalse(CharSequences.equalIgnoreCase("", "EFG"));
        assertFalse(CharSequences.equalIgnoreCase("abc", "abc "));
        assertFalse(CharSequences.equalIgnoreCase("abc", " abc"));
     }
  
  
  
  
  
     @Test
     public void testIndexOfChar()
     {
        assertEquals(-1, CharSequences.indexOf(null, 'a'));
        assertEquals(-1, CharSequences.indexOf("", 'a'));
        assertEquals(-1, CharSequences.indexOf("abc", 'd'));
        assertEquals(-1, CharSequences.indexOf("abc", ' '));
  
        assertEquals(0, CharSequences.indexOf("abc", 'a'));
        assertEquals(1, CharSequences.indexOf("abc", 'b'));
        assertEquals(2, CharSequences.indexOf("abc", 'c'));
     }
  
     @Test
     public void testIndexOfCharByPosition()
     {
        assertEquals(-1, CharSequences.indexOf(null, 'a', 0));
        assertEquals(-1, CharSequences.indexOf(null, 'a', 4));
        assertEquals(-1, CharSequences.indexOf("", 'a', -4));
        assertEquals(-1, CharSequences.indexOf("", 'a', -1));
        assertEquals(-1, CharSequences.indexOf("abc", 'c', 4));
        assertEquals(-1, CharSequences.indexOf("abc", ' ', 0));
  
        assertEquals(0, CharSequences.indexOf("abc", 'a', 0));
        assertEquals(1, CharSequences.indexOf("abc", 'b', 1));
        assertEquals(2, CharSequences.indexOf("abc", 'c', 2));
  
        assertEquals(5, CharSequences.indexOf("abcabc", 'c', 3));
        assertEquals(2, CharSequences.indexOf("abcabc", 'c', -1));
     }
  
     @Test
     public void testIndexOf()
     {
        assertEquals(-1, CharSequences.indexOf(null, "a"));
        assertEquals(-1, CharSequences.indexOf(null, null));
        assertEquals(-1, CharSequences.indexOf("a", null));
        assertEquals(-1, CharSequences.indexOf("", "a"));
        assertEquals(-1, CharSequences.indexOf("abc", "d"));
        assertEquals(-1, CharSequences.indexOf("abc", " "));
        assertEquals(-1, CharSequences.indexOf("abc", "abcd"));
  
        assertEquals(0, CharSequences.indexOf("abc", "a"));
        assertEquals(1, CharSequences.indexOf("abc", "b"));
        assertEquals(2, CharSequences.indexOf("abc", "c"));
  
        assertEquals(1, CharSequences.indexOf("abcabc", "bc"));
        assertEquals(2, CharSequences.indexOf("abcabc", "ca"));
        assertEquals(0, CharSequences.indexOf("abcabc", "ab"));
        assertEquals(4, CharSequences.indexOf("abcabe", "be"));
        assertEquals(2, CharSequences.indexOf("abcabe", "cab"));
        assertEquals(2, CharSequences.indexOf("abcabe", "cabe"));
        assertEquals(0, CharSequences.indexOf("abcabe", "abcabe"));
     }
  
     @Test
     public void testIndexOfByPosition()
     {
        assertEquals(-1, CharSequences.indexOf(null, "a", 0));
        assertEquals(-1, CharSequences.indexOf(null, "a", 5));
        assertEquals(-1, CharSequences.indexOf(null, "a", -5));
        assertEquals(-1, CharSequences.indexOf("", "", 1));
  
        assertEquals(-1, CharSequences.indexOf("a", null, 0));
        assertEquals(-1, CharSequences.indexOf("a", null, 5));
        assertEquals(-1, CharSequences.indexOf("a", null, -5));
  
        assertEquals(0, CharSequences.indexOf("", "", -1));
        assertEquals(0, CharSequences.indexOf("", "", 0));
  
        assertEquals(0, CharSequences.indexOf("abcabc", "ab", 0));
        assertEquals(3, CharSequences.indexOf("abcabc", "ab", 1));
        assertEquals(3, CharSequences.indexOf("abcabc", "ab", 3));
  
        assertEquals(1, CharSequences.indexOf("abcabc", "bc", -3));
        assertEquals(4, CharSequences.indexOf("abcabc", "bc", 3));
        assertEquals(3, CharSequences.indexOf("abcabc", "abc", 3));
  
        assertEquals(-1, CharSequences.indexOf("abcabc", "abc", 4));
  
        assertEquals(0, CharSequences.indexOf("abcabc", "abcabc", 0));
        assertEquals(-1, CharSequences.indexOf("abcabc", "abcabc", 1));
     }
  
     @Test
     public void testIndexOfIgnoreCase()
     {
        assertEquals(-1, CharSequences.indexOfIgnoreCase(null, "a"));
        assertEquals(-1, CharSequences.indexOfIgnoreCase(null, null));
        assertEquals(-1, CharSequences.indexOfIgnoreCase("a", null));
        assertEquals(-1, CharSequences.indexOfIgnoreCase("", "a"));
        assertEquals(-1, CharSequences.indexOfIgnoreCase("abc", "d"));
        assertEquals(-1, CharSequences.indexOfIgnoreCase("abc", " "));
        assertEquals(-1, CharSequences.indexOfIgnoreCase("abc", "abcd"));
  
        assertEquals(0, CharSequences.indexOfIgnoreCase("ABC", "a"));
        assertEquals(1, CharSequences.indexOfIgnoreCase("ABC", "b"));
        assertEquals(2, CharSequences.indexOfIgnoreCase("ABC", "c"));
  
        assertEquals(0, CharSequences.indexOfIgnoreCase("abc", "A"));
        assertEquals(1, CharSequences.indexOfIgnoreCase("abc", "B"));
        assertEquals(2, CharSequences.indexOfIgnoreCase("abc", "C"));
  
        assertEquals(1, CharSequences.indexOfIgnoreCase("ABCABC", "bc"));
        assertEquals(2, CharSequences.indexOfIgnoreCase("ABCABC", "ca"));
        assertEquals(0, CharSequences.indexOfIgnoreCase("ABCABC", "ab"));
        assertEquals(4, CharSequences.indexOfIgnoreCase("ABCABE", "be"));
        assertEquals(2, CharSequences.indexOfIgnoreCase("ABCABE", "cab"));
        assertEquals(2, CharSequences.indexOfIgnoreCase("ABCABE", "cabe"));
        assertEquals(0, CharSequences.indexOfIgnoreCase("ABCABE", "abcabe"));
  
        assertEquals(1, CharSequences.indexOfIgnoreCase("abcabc", "BC"));
        assertEquals(2, CharSequences.indexOfIgnoreCase("abcabc", "CA"));
        assertEquals(0, CharSequences.indexOfIgnoreCase("abcabc", "AB"));
        assertEquals(4, CharSequences.indexOfIgnoreCase("abcabe", "Be"));
        assertEquals(2, CharSequences.indexOfIgnoreCase("abcabe", "CaB"));
        assertEquals(2, CharSequences.indexOfIgnoreCase("abcabe", "cABE"));
        assertEquals(0, CharSequences.indexOfIgnoreCase("abcabe", "ABCabe"));
     }
  
     @Test
     public void testIndexOfIgnoreCaseByPosition()
     {
        assertEquals(-1, CharSequences.indexOfIgnoreCase(null, "a", 0));
        assertEquals(-1, CharSequences.indexOfIgnoreCase(null, "a", 5));
        assertEquals(-1, CharSequences.indexOfIgnoreCase(null, "a", -5));
        assertEquals(-1, CharSequences.indexOfIgnoreCase("", "", 1));
  
        assertEquals(-1, CharSequences.indexOfIgnoreCase("a", null, 0));
        assertEquals(-1, CharSequences.indexOfIgnoreCase("a", null, 5));
        assertEquals(-1, CharSequences.indexOfIgnoreCase("a", null, -5));
  
        assertEquals(0, CharSequences.indexOfIgnoreCase("", "", -1));
        assertEquals(0, CharSequences.indexOfIgnoreCase("", "", 0));
  
        assertEquals(0, CharSequences.indexOfIgnoreCase("ABCABC", "ab", 0));
        assertEquals(3, CharSequences.indexOfIgnoreCase("ABCABC", "ab", 1));
        assertEquals(3, CharSequences.indexOfIgnoreCase("ABCABC", "ab", 3));
        assertEquals(0, CharSequences.indexOfIgnoreCase("abcabc", "AB", 0));
        assertEquals(3, CharSequences.indexOfIgnoreCase("abcabc", "AB", 1));
        assertEquals(3, CharSequences.indexOfIgnoreCase("abcabc", "AB", 3));
  
  
        assertEquals(1, CharSequences.indexOfIgnoreCase("ABCABC", "bc", -3));
        assertEquals(4, CharSequences.indexOfIgnoreCase("ABCABC", "bc", 3));
        assertEquals(3, CharSequences.indexOfIgnoreCase("ABCABC", "abc", 3));
  
        assertEquals(1, CharSequences.indexOfIgnoreCase("abcabc", "BC", -3));
        assertEquals(4, CharSequences.indexOfIgnoreCase("abcabc", "BC", 3));
        assertEquals(3, CharSequences.indexOfIgnoreCase("abcabc", "ABC", 3));
  
  
        assertEquals(-1, CharSequences.indexOfIgnoreCase("abcabc", "ABC", 4));
        assertEquals(-1, CharSequences.indexOfIgnoreCase("ABCABC", "abc", 4));
  
        assertEquals(0, CharSequences.indexOfIgnoreCase("abcabc", "abcabc", 0));
        assertEquals(-1, CharSequences.indexOfIgnoreCase("abcabc", "abcabc", 1));
     }
  
  
     @Test
     public void testLastIndexOfChar()
     {
        assertEquals(-1, CharSequences.lastIndexOf(null, 'c'));
        assertEquals(-1, CharSequences.lastIndexOf("", 'c'));
  
        assertEquals(7, CharSequences.lastIndexOf("aabaabaa", 'a'));
        assertEquals(5, CharSequences.lastIndexOf("aabaabaa", 'b'));
  
  