diff --git a/src/test/java/org/apache/commons/lang3/CharRangeTest.java b/src/test/java/org/apache/commons/lang3/CharRangeTest.java index 575d7809f..b36e43e7a 100644 --- a/src/test/java/org/apache/commons/lang3/CharRangeTest.java +++ b/src/test/java/org/apache/commons/lang3/CharRangeTest.java @@ -397,4 +397,11 @@ public class CharRangeTest { assertEquals(range, SerializationUtils.clone(range)); } + //----------------------------------------------------------------------- + @Test(expected = UnsupportedOperationException.class) + public void testIteratorRemove() { + CharRange a = CharRange.is('a'); + final Iterator aIt = a.iterator(); + aIt.remove(); + } } diff --git a/src/test/java/org/apache/commons/lang3/RandomUtilsTest.java b/src/test/java/org/apache/commons/lang3/RandomUtilsTest.java index a46a36ab8..ed032e70e 100644 --- a/src/test/java/org/apache/commons/lang3/RandomUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/RandomUtilsTest.java @@ -16,12 +16,17 @@ */ package org.apache.commons.lang3; +import static junit.framework.TestCase.assertNotNull; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import org.junit.Test; +import java.lang.reflect.Constructor; +import java.lang.reflect.Modifier; + /** * Tests for {@link RandomUtils} */ @@ -32,6 +37,15 @@ public class RandomUtilsTest { */ private static final double DELTA = 1e-5; + @Test + public void testConstructor() { + assertNotNull(new RandomUtils()); + final Constructor[] cons = RandomUtils.class.getDeclaredConstructors(); + assertEquals(1, cons.length); + assertTrue(Modifier.isPublic(cons[0].getModifiers())); + assertTrue(Modifier.isPublic(RandomUtils.class.getModifiers())); + assertFalse(Modifier.isFinal(RandomUtils.class.getModifiers())); + } @Test(expected = IllegalArgumentException.class) public void testNextBytesNegative() throws Exception { @@ -78,6 +92,15 @@ public class RandomUtilsTest { RandomUtils.nextFloat(2, 1); } + /** + * Tests next boolean + */ + @Test + public void testBoolean() { + boolean result = RandomUtils.nextBoolean(); + assertTrue(result == true || result == false); + } + /** * Tests a zero byte array length. */ diff --git a/src/test/java/org/apache/commons/lang3/StringEscapeUtilsTest.java b/src/test/java/org/apache/commons/lang3/StringEscapeUtilsTest.java index 815dc966f..b279c3121 100644 --- a/src/test/java/org/apache/commons/lang3/StringEscapeUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/StringEscapeUtilsTest.java @@ -199,6 +199,29 @@ public class StringEscapeUtilsTest { StringEscapeUtils.escapeEcmaScript("document.getElementById(\"test\").value = '';")); } + @Test + public void testUnescapeEcmaScript() { + assertEquals(null, StringEscapeUtils.escapeEcmaScript(null)); + try { + StringEscapeUtils.UNESCAPE_ECMASCRIPT.translate(null, null); + fail(); + } catch (final IOException ex) { + fail(); + } catch (final IllegalArgumentException ex) { + } + try { + StringEscapeUtils.UNESCAPE_ECMASCRIPT.translate("", null); + fail(); + } catch (final IOException ex) { + fail(); + } catch (final IllegalArgumentException ex) { + } + + assertEquals("He didn't say, \"stop!\"", StringEscapeUtils.unescapeEcmaScript("He didn\\'t say, \\\"stop!\\\"")); + assertEquals("document.getElementById(\"test\").value = '';", + StringEscapeUtils.unescapeEcmaScript("document.getElementById(\\\"test\\\").value = \\'