You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2023/09/30 16:39:49 UTC
[commons-text] branch master updated: Simplify test exception handling
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git
The following commit(s) were added to refs/heads/master by this push:
new 0f467da3 Simplify test exception handling
0f467da3 is described below
commit 0f467da3717c27c98cc213b3c0a92ae06fcd5854
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Sep 30 12:39:14 2023 -0400
Simplify test exception handling
---
.../apache/commons/text/StringEscapeUtilsTest.java | 28 ++++++++--------------
1 file changed, 10 insertions(+), 18 deletions(-)
diff --git a/src/test/java/org/apache/commons/text/StringEscapeUtilsTest.java b/src/test/java/org/apache/commons/text/StringEscapeUtilsTest.java
index de1ebdd7..d32d4ac9 100644
--- a/src/test/java/org/apache/commons/text/StringEscapeUtilsTest.java
+++ b/src/test/java/org/apache/commons/text/StringEscapeUtilsTest.java
@@ -94,24 +94,16 @@ public class StringEscapeUtilsTest {
assertEquals(unescaped, writer.toString());
}
- private void checkCsvEscapeWriter(final String expected, final String value) {
- try {
- final StringWriter writer = new StringWriter();
- StringEscapeUtils.ESCAPE_CSV.translate(value, writer);
- assertEquals(expected, writer.toString());
- } catch (final IOException e) {
- fail("Threw: " + e);
- }
+ private void checkCsvEscapeWriter(final String expected, final String value) throws IOException {
+ final StringWriter writer = new StringWriter();
+ StringEscapeUtils.ESCAPE_CSV.translate(value, writer);
+ assertEquals(expected, writer.toString());
}
- private void checkCsvUnescapeWriter(final String expected, final String value) {
- try {
- final StringWriter writer = new StringWriter();
- StringEscapeUtils.UNESCAPE_CSV.translate(value, writer);
- assertEquals(expected, writer.toString());
- } catch (final IOException e) {
- fail("Threw: " + e);
- }
+ private void checkCsvUnescapeWriter(final String expected, final String value) throws IOException {
+ final StringWriter writer = new StringWriter();
+ StringEscapeUtils.UNESCAPE_CSV.translate(value, writer);
+ assertEquals(expected, writer.toString());
}
@Test
@@ -152,7 +144,7 @@ public class StringEscapeUtilsTest {
}
@Test
- public void testEscapeCsvWriter() {
+ public void testEscapeCsvWriter() throws IOException {
checkCsvEscapeWriter("foo.bar", "foo.bar");
checkCsvEscapeWriter("\"foo,bar\"", "foo,bar");
checkCsvEscapeWriter("\"foo\nbar\"", "foo\nbar");
@@ -467,7 +459,7 @@ public void testEscapeEcmaScript() {
}
@Test
- public void testUnescapeCsvWriter() {
+ public void testUnescapeCsvWriter() throws IOException {
checkCsvUnescapeWriter("foo.bar", "foo.bar");
checkCsvUnescapeWriter("foo,bar", "\"foo,bar\"");
checkCsvUnescapeWriter("foo\nbar", "\"foo\nbar\"");