result = StringUtils.split("one two three four five six", null, 2); assertEquals("split(Object[], null, int)[0] failed", "one", result[0]); assertEquals("split(Object[], null, int)[1] failed", "two", result[1]); assertEquals("split(Object[], null, int)[2] failed", "three four five six", result[2]);
    public void testSplit()    {        String[] result = StringUtils.split(TEXT_LIST, SEPARATOR, 2);        String[] expected = { "foo", "bar,baz" };        assertEquals("split(Object[], String, int) yielded unexpected length",                     expected.length, result.length);        for (int i = 0; i < result.length; i++)        {            assertEquals("split(Object[], String, int) failed", expected[i],                         result[i]);        }        result = StringUtils.split(TEXT_LIST, SEPARATOR, 0);        expected = ARRAY_LIST;        assertEquals("split(Object[], String, int) yielded unexpected length",                     expected.length, result.length);        for (int i = 0; i < result.length; i++)        {            assertEquals("split(Object[], String, int) failed", expected[i],                         result[i]);        }        result = StringUtils.split(TEXT_LIST, SEPARATOR, -1);        expected = ARRAY_LIST;        assertEquals("split(Object[], String, int) yielded unexpected length",                     expected.length, result.length);        for (int i = 0; i < result.length; i++)        {            assertEquals("split(Object[], String, int) failed", expected[i],                         result[i]);        }    }