On 22 February 2017 at 16:48, Benedikt Ritter <[email protected]> wrote:
> Hi,
>
>> Am 22.02.2017 um 17:33 schrieb [email protected]:
>>
>> Repository: commons-text
>> Updated Branches:
>> refs/heads/master e9273cd4b -> a0077dd37
>>
>>
>> HTML3 tests
>>
>> Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo
>> Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/a0077dd3
>> Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/a0077dd3
>> Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/a0077dd3
>>
>> Branch: refs/heads/master
>> Commit: a0077dd37dc112a83cb24eccab702202c2bc8a13
>> Parents: e9273cd
>> Author: Sebb <[email protected]>
>> Authored: Wed Feb 22 16:33:37 2017 +0000
>> Committer: Sebb <[email protected]>
>> Committed: Wed Feb 22 16:33:37 2017 +0000
>>
>> ----------------------------------------------------------------------
>> .../commons/text/StringEscapeUtilsTest.java | 46 +++++++++++++++++++-
>> 1 file changed, 45 insertions(+), 1 deletion(-)
>> ----------------------------------------------------------------------
>>
>>
>> http://git-wip-us.apache.org/repos/asf/commons-text/blob/a0077dd3/src/test/java/org/apache/commons/text/StringEscapeUtilsTest.java
>> ----------------------------------------------------------------------
>> diff --git
>> a/src/test/java/org/apache/commons/text/StringEscapeUtilsTest.java
>> b/src/test/java/org/apache/commons/text/StringEscapeUtilsTest.java
>> index ef9d8ab..4de4fea 100644
>> --- a/src/test/java/org/apache/commons/text/StringEscapeUtilsTest.java
>> +++ b/src/test/java/org/apache/commons/text/StringEscapeUtilsTest.java
>> @@ -224,7 +224,51 @@ public class StringEscapeUtilsTest {
>> };
>>
>> @Test
>> - public void testEscapeHtml() {
>> + public void testEscapeHtml3() {
>> + for (final String[] element : HTML_ESCAPES) {
>> + final String message = element[0];
>> + final String expected = element[1];
>> + final String original = element[2];
>> + assertEquals(message, expected,
>> StringEscapeUtils.escapeHtml4(original));
>> + final StringWriter sw = new StringWriter();
>> + try {
>> + StringEscapeUtils.ESCAPE_HTML3.translate(original, sw);
>> + } catch (final IOException e) {
>
> How about declaring the exception in the method signature? This way you don’t
> need to catch it and JUnit will produce an error in the test report if it is
> thrown.
>
These were created as copies of existing methods and I changed the
minimum necessary.
But I agree they could all be simplified.
>> + }
>> + final String actual = original == null ? null : sw.toString();
>> + assertEquals(message, expected, actual);
>> + }
>> + }
>> +
>> + @Test
>> + public void testUnescapeHtml3() {
>> + for (final String[] element : HTML_ESCAPES) {
>> + final String message = element[0];
>> + final String expected = element[2];
>> + final String original = element[1];
>> + assertEquals(message, expected,
>> StringEscapeUtils.unescapeHtml3(original));
>> +
>> + final StringWriter sw = new StringWriter();
>> + try {
>> + StringEscapeUtils.UNESCAPE_HTML3.translate(original, sw);
>> + } catch (final IOException e) {
>> + }
>> + final String actual = original == null ? null : sw.toString();
>> + assertEquals(message, expected, actual);
>> + }
>> + // \u00E7 is a cedilla (c with wiggle under)
>> + // note that the test string must be 7-bit-clean (Unicode escaped)
>> or else it will compile incorrectly
>> + // on some locales
>> + assertEquals("funny chars pass through OK", "Fran\u00E7ais",
>> StringEscapeUtils.unescapeHtml3("Fran\u00E7ais"));
>> +
>> + assertEquals("Hello&;World",
>> StringEscapeUtils.unescapeHtml3("Hello&;World"));
>> + assertEquals("Hello&#;World",
>> StringEscapeUtils.unescapeHtml3("Hello&#;World"));
>> + assertEquals("Hello&# ;World",
>> StringEscapeUtils.unescapeHtml3("Hello&# ;World"));
>> + assertEquals("Hello&##;World",
>> StringEscapeUtils.unescapeHtml3("Hello&##;World"));
>> + }
>> +
>> +@Test
>> + public void testEscapeHtml4() {
>> for (final String[] element : HTML_ESCAPES) {
>> final String message = element[0];
>> final String expected = element[1];
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]