Words { public static String initials(String str) { return initials(str, null); } private  Words(); static String wrap(String str, int wrapLength); static String wrap(String str, int wrapLength, String newLineStr, boolean wrapLongWords); static String capitalize(String str); static String capitalize(String str, char[] delimiters); static String capitalizeFully(String str); static String capitalizeFully(String str, char[] delimiters); static String uncapitalize(String str); static String uncapitalize(String str, char[] delimiters); static String initials(String str); static String initials(String str, char[] delimiters);  }
@Test public void testInitials_String() { assertEquals(null, initials(null)); assertEquals("", initials("")); assertEquals("", initials(" ")); assertEquals("I", initials("I")); assertEquals("i", initials("i")); assertEquals("BJL", initials("Ben John Lee")); assertEquals("BJ", initials("Ben J.Lee")); assertEquals("BJ.L", initials(" Ben John . Lee")); assertEquals("iah1", initials("i am here 123")); }
@Test public void testInitials_String_charArray() { char[] array = null; assertEquals(null, initials(null, array)); assertEquals("", initials("", array)); assertEquals("", initials(" ", array)); assertEquals("I", initials("I", array)); assertEquals("i", initials("i", array)); assertEquals("S", initials("SJC", array)); assertEquals("BJL", initials("Ben John Lee", array)); assertEquals("BJ", initials("Ben J.Lee", array)); assertEquals("BJ.L", initials(" Ben John . Lee", array)); assertEquals("KO", initials("Kay O'Murphy", array)); assertEquals("iah1", initials("i am here 123", array)); array = new char[0]; assertEquals(null, initials(null, array)); assertEquals("", initials("", array)); assertEquals("", initials(" ", array)); assertEquals("", initials("I", array)); assertEquals("", initials("i", array)); assertEquals("", initials("SJC", array)); assertEquals("", initials("Ben John Lee", array)); assertEquals("", initials("Ben J.Lee", array)); assertEquals("", initials(" Ben John . Lee", array)); assertEquals("", initials("Kay O'Murphy", array)); assertEquals("", initials("i am here 123", array)); array = " ".toCharArray(); assertEquals(null, initials(null, array)); assertEquals("", initials("", array)); assertEquals("", initials(" ", array)); assertEquals("I", initials("I", array)); assertEquals("i", initials("i", array)); assertEquals("S", initials("SJC", array)); assertEquals("BJL", initials("Ben John Lee", array)); assertEquals("BJ", initials("Ben J.Lee", array)); assertEquals("BJ.L", initials(" Ben John . Lee", array)); assertEquals("KO", initials("Kay O'Murphy", array)); assertEquals("iah1", initials("i am here 123", array)); array = " .".toCharArray(); assertEquals(null, initials(null, array)); assertEquals("", initials("", array)); assertEquals("", initials(" ", array)); assertEquals("I", initials("I", array)); assertEquals("i", initials("i", array)); assertEquals("S", initials("SJC", array)); assertEquals("BJL", initials("Ben John Lee", array)); assertEquals("BJL", initials("Ben J.Lee", array)); assertEquals("BJL", initials(" Ben John . Lee", array)); assertEquals("KO", initials("Kay O'Murphy", array)); assertEquals("iah1", initials("i am here 123", array)); array = " .'".toCharArray(); assertEquals(null, initials(null, array)); assertEquals("", initials("", array)); assertEquals("", initials(" ", array)); assertEquals("I", initials("I", array)); assertEquals("i", initials("i", array)); assertEquals("S", initials("SJC", array)); assertEquals("BJL", initials("Ben John Lee", array)); assertEquals("BJL", initials("Ben J.Lee", array)); assertEquals("BJL", initials(" Ben John . Lee", array)); assertEquals("KOM", initials("Kay O'Murphy", array)); assertEquals("iah1", initials("i am here 123", array)); array = "SIJo1".toCharArray(); assertEquals(null, initials(null, array)); assertEquals("", initials("", array)); assertEquals(" ", initials(" ", array)); assertEquals("", initials("I", array)); assertEquals("i", initials("i", array)); assertEquals("C", initials("SJC", array)); assertEquals("Bh", initials("Ben John Lee", array)); assertEquals("B.", initials("Ben J.Lee", array)); assertEquals(" h", initials(" Ben John . Lee", array)); assertEquals("K", initials("Kay O'Murphy", array)); assertEquals("i2", initials("i am here 123", array)); }