1717package org .apache .commons .io .input ;
1818
1919import static org .junit .jupiter .api .Assertions .assertEquals ;
20+ import static org .junit .jupiter .api .Assertions .assertThrows ;
2021import static org .junit .jupiter .api .Assertions .assertTrue ;
21- import static org .junit .jupiter .api .Assertions .fail ;
2222
2323import java .io .ByteArrayInputStream ;
2424import java .io .ByteArrayOutputStream ;
@@ -214,18 +214,10 @@ private void checkArray(final char[] expected, final char[] actual) {
214214
215215 @ Test
216216 public void testConstructor () {
217- try {
218- new CharSequenceReader ("FooBar" , -1 , 6 );
219- fail ("Expected exception not thrown for negative start." );
220- } catch (IllegalArgumentException e ) {
221- // expected
222- }
223- try {
224- new CharSequenceReader ("FooBar" , 1 , 0 );
225- fail ("Expected exception not thrown for end before start." );
226- } catch (IllegalArgumentException e ) {
227- // expected
228- }
217+ assertThrows (IllegalArgumentException .class , () -> new CharSequenceReader ("FooBar" , -1 , 6 ),
218+ "Expected exception not thrown for negative start." );
219+ assertThrows (IllegalArgumentException .class , () -> new CharSequenceReader ("FooBar" , 1 , 0 ),
220+ "Expected exception not thrown for end before start." );
229221 }
230222
231223 @ Test
@@ -238,7 +230,7 @@ public void testToString() {
238230 public void testSerialization () throws IOException , ClassNotFoundException {
239231 /*
240232 * File CharSequenceReader.bin contains a CharSequenceReader that was serialized before
241- * the start and end fields were added. Its CharSequecne is "FooBar".
233+ * the start and end fields were added. Its CharSequence is "FooBar".
242234 * This part of the test will test that adding the fields does not break any existing
243235 * serialized CharSequenceReaders.
244236 */
0 commit comments