@Test public void testIsNotNullOrEmpty() { assertFalse(StringUtil.isNotNullOrEmpty(null)); assertFalse(StringUtil.isNotNullOrEmpty("")); assertFalse(StringUtil.isNotNullOrEmpty(" ", true)); assertTrue(StringUtil.isNotNullOrEmpty(" ", false)); }
@Test public void testPadCenterChar() { String test1 = StringUtil.padCenter("test", '+', 10); assertEquals("+++test+++", test1); String test2 = StringUtil.padCenter("tst", '+', 10); assertEquals("+++tst++++", test2); }
@Test public void testIsBooleanValue() { assertTrue(StringUtil.isBooleanValue("TRUE")); assertTrue(StringUtil.isBooleanValue("FALSE")); assertTrue(StringUtil.isBooleanValue("true")); assertTrue(StringUtil.isBooleanValue("False")); assertFalse(StringUtil.isBooleanValue("error")); }
@Test public void testPadCenterSpace() { String test1 = StringUtil.padCenter("test", 10); assertEquals(" test ", test1); String test2 = StringUtil.padCenter("tst", 10); assertEquals(" tst ", test2); }
@Test public void testSourcesContainsTargets() { String sources[] = {"one", "two", "three", "four", "five"}; String targets1[] = {"apple", "orange", "bananna", "peach", "pear"}; String targets2[] = {"qq", "zz", "tw", "uu", "yy"}; assertTrue(StringUtil.contains(sources, targets2)); assertFalse(StringUtil.contains(sources, targets1)); }
@Test public void testRemoveLinebreakCharacters() { assertEquals(StringUtil.removeLinebreakCharacters("abc\r\nabc"), "abc abc"); assertEquals(StringUtil.removeLinebreakCharacters("abc\rabc"), "abc abc"); assertEquals(StringUtil.removeLinebreakCharacters("abc\nabc"), "abc abc"); assertEquals(StringUtil.removeLinebreakCharacters("abc abc"), "abc abc"); assertEquals(StringUtil.removeLinebreakCharacters("abc\r\r\r\r\rabc"), "abc abc"); assertEquals(StringUtil.removeLinebreakCharacters("abc\r\n\n\r\rabc"), "abc abc"); assertEquals(StringUtil.removeLinebreakCharacters("\nabc abc"), " abc abc"); assertEquals(StringUtil.removeLinebreakCharacters("\r"), " "); }
@Test public void testAppend() { assertEquals(StringUtil.append("abc", "|", "abc"), "abc|abc"); assertEquals(StringUtil.append("abc", "", "abc"), "abcabc"); assertEquals(StringUtil.append(null, "|", "b"), "b"); assertEquals(StringUtil.append("", "|", "b"), "b"); assertEquals(StringUtil.append("abc", "|", null), "abc|null"); assertEquals(StringUtil.append("abc", null, "abc"), "abcnullabc"); assertEquals(StringUtil.append(null, null, null), null); }
@Test public void testRemoveDuplicateWhitespace() { assertEquals(StringUtil.removeDuplicateWhitespace("abc abc"), "abc abc"); assertEquals(StringUtil.removeDuplicateWhitespace("abc abc"), "abc abc"); assertEquals(StringUtil.removeDuplicateWhitespace("abcabc"), "abcabc"); assertEquals(StringUtil.removeDuplicateWhitespace("abc abc"), "abc abc"); assertEquals(StringUtil.removeDuplicateWhitespace(" "), " "); assertEquals(StringUtil.removeDuplicateWhitespace(""), ""); }
@Test public void testSourceContainsTargets() { String targets[] = {"one", "two", "three", "four", "five"}; assertTrue(StringUtil.contains("This is one fine day!", targets)); assertFalse(StringUtil.contains("This is not a fine day!", targets)); }
@Test public void testSourcesContainsTarget() { String sources[] = {"one", "two", "three", "four", "five"}; assertTrue(StringUtil.contains(sources, "ou")); assertFalse(StringUtil.contains(sources, "+")); }
@Test public void testSourceContainsTarget() { assertTrue(StringUtil.contains("source-data-source", "data")); assertFalse(StringUtil.contains("source-data-source", "****")); }
@Test public void testIsLongValue() { assertTrue(StringUtil.isLongValue("10")); assertFalse(StringUtil.isLongValue("0.1")); assertFalse(StringUtil.isLongValue("A")); }
@Test public void testTrimChar() { String test = StringUtil.trim("...this is a test...", '.'); assertEquals("this is a test", test); }
@Test public void testCreateChar() { String test = StringUtil.create('-', 5); assertEquals("-----", test); }
@Test public void testPadBothString() { String test = StringUtil.pad("test-data", "<>", 5); assertEquals("<><><><><>test-data<><><><><>", test); }
@Test public void testPadBothChar() { String test = StringUtil.pad("test-data", '+', 5); assertEquals("+++++test-data+++++", test); }
@Test public void testPadBothSpace() { String test = StringUtil.pad("test-data", 5); assertEquals(" test-data ", test); }
@Test public void testPadRightChar() { String test = StringUtil.padRight("test-data", '+', 5); assertEquals("test-data+++++", test); }
@Test public void testCreateSpace() { String test = StringUtil.create(5); assertEquals(" ", test); }
@Test public void testIsIntValue() { assertTrue(StringUtil.isIntValue("-10")); assertFalse(StringUtil.isIntValue("1-1")); }
@Test public void testCreateString() { String test = StringUtil.create("+-", 5); assertEquals("+-+-+-+-+-", test); }
@Test public void testTrimSpace() { String test = StringUtil.trim(" this is a test "); assertEquals("this is a test", test); }